Skip to main content

Console

Struct Console 

Source
pub struct Console<O: Write + Send, E: Write + Send> { /* private fields */ }
Expand description

console: line-oriented output on two streams.

The two writers are the whole of the difference between the streams. What a program produces goes to out through println and print; what it says about what it produces goes to err through eprintln and eprint, and a host that wants the two apart is a host that hands over two different writers. cove run gives the process’s stdout and stderr, which is why a program’s records can now be piped somewhere while its complaints stay on the terminal.

The two streams are one capability. All four operations require console, so a run that may print may complain, and this type is where the difference between the streams is: an embedding that wants a program’s output captured while its complaints reach the terminal hands over a buffer and std::io::stderr(), which is a wiring choice rather than an authority one. Nothing here consults the grants at all — the boundary has already decided by the time an operation arrives.

§Migrating from the one-writer form

Console::new took one writer and now takes two. The second is where diagnostics go, and there is deliberately no default: a host that captured a program’s output before this existed would silently start capturing its diagnostics too, which is exactly the mixing the second stream is for undoing. Console::new(w) therefore fails to compile rather than changing meaning. An embedding that genuinely wants one stream says so — Console::new(w.clone(), w) for a shared writer, Console::new(w, std::io::sink()) to drop diagnostics — and one that wants the process’s streams writes Console::new(std::io::stdout(), std::io::stderr()).

Implementations§

Source§

impl<O: Write + Send, E: Write + Send> Console<O, E>

Source

pub fn new(out: O, err: E) -> Self

A console whose output goes to out and whose diagnostics go to err.

Trait Implementations§

Source§

impl<O: Write + Send, E: Write + Send> HostApi for Console<O, E>

Source§

fn module_schema(&self) -> ModuleSchema

The whole of what this module declares about itself: the name Cove source uses, the capability a host must grant for it, the operations it exposes, the types it declares, and the kinds of resource it can open. Read more
Source§

fn call(&self, op: &str, args: Vec<Value>) -> Result<Value, RuntimeError>

Invokes one operation.
Source§

fn call_with( &self, op: &str, args: Vec<Value>, back: &mut dyn Reentry, ) -> Result<Value, RuntimeError>

Invokes one operation. Read more
Source§

fn call_resource( &self, handle: &ResourceHandle, op: &str, args: Vec<Value>, back: &mut dyn Reentry, ) -> Result<Value, RuntimeError>

Invokes one operation on a handle this module issued. Read more

Auto Trait Implementations§

§

impl<O, E> !Freeze for Console<O, E>

§

impl<O, E> RefUnwindSafe for Console<O, E>

§

impl<O, E> Send for Console<O, E>

§

impl<O, E> Sync for Console<O, E>

§

impl<O, E> Unpin for Console<O, E>
where O: Unpin, E: Unpin,

§

impl<O, E> UnsafeUnpin for Console<O, E>
where O: UnsafeUnpin, E: UnsafeUnpin,

§

impl<O, E> UnwindSafe for Console<O, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.