diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index e4597c73..60ec08f3 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -358,7 +358,7 @@ impl<'a> Runtime<'a> { use std::rc::Rc; use std::cell::RefCell; - let mut input = ::std::io::empty(); + let mut input = ::std::io::stdin(); let output = ::std::io::stdout(); let output = Rc::new(RefCell::new(output)); let mapper = JsonMapper::new(); @@ -372,6 +372,25 @@ impl<'a> Runtime<'a> { }) } + pub fn store_backend_to_stdout(&mut self) -> Result<(), RuntimeError> { + use libimagstore::file_abstraction::stdio::mapper::json::JsonMapper; + use libimagstore::file_abstraction::stdio::out::StdoutFileAbstraction; + use std::rc::Rc; + use std::cell::RefCell; + + let output = ::std::io::stdout(); + let output = Rc::new(RefCell::new(output)); + let mapper = JsonMapper::new(); + + StdoutFileAbstraction::new(output, mapper) + .map_err_into(RuntimeErrorKind::Instantiate) + .and_then(|backend| { + self.store + .reset_backend(Box::new(backend)) + .map_err_into(RuntimeErrorKind::Instantiate) + }) + } + /// Get a editor command object which can be called to open the $EDITOR pub fn editor(&self) -> Option { self.cli()