InMemoryOutput

Struct InMemoryOutput 

Source
pub struct InMemoryOutput<Ctx> { /* private fields */ }
Expand description

An output implementation that just writes to a string. Produces no errors and the futures complete instantly. This type is an analogue of InMemoryIo.

Implementations§

Source§

impl<Ctx> InMemoryOutput<Ctx>

Source

pub fn new(context: Ctx) -> Self

Source§

impl<Ctx> InMemoryOutput<Ctx>
where Ctx: Context,

Source

pub fn print_output<W>(context: Ctx, writable: &W) -> String
where W: Writable<Self>,

Gets the string output of a single writable.

Assumes that the only source of async is this InMemoryOutput itself, i.e. the writable will never return a pending future unless the output used with it returns a pending future.

Panics if the writable returns a pending future (particularly, this may happen if a writable introduces its own async computations that do not come from the output)

Trait Implementations§

Source§

impl<Ctx> Output for InMemoryOutput<Ctx>
where Ctx: Context,

Source§

type Io<'b> = InMemoryIo<'b> where Self: 'b

The I/O stream type
Source§

type Ctx = Ctx

The context holder
Source§

type Error = Infallible

The error type for write operations.
Source§

async fn write(&mut self, value: &str) -> Result<(), Self::Error>

Writes the given value to the output.
Source§

fn split(&mut self) -> (Self::Io<'_>, &Self::Ctx)

Splits into the context and the I/O stream, so that they can be used separately
Source§

fn context(&self) -> &Self::Ctx

Gets all the context associated with this output
Source§

fn get_ctx<T>(&self) -> &T
where Self::Ctx: ContextProvides<T>,

Gets a particular context value

Auto Trait Implementations§

§

impl<Ctx> Freeze for InMemoryOutput<Ctx>
where Ctx: Freeze,

§

impl<Ctx> RefUnwindSafe for InMemoryOutput<Ctx>
where Ctx: RefUnwindSafe,

§

impl<Ctx> Send for InMemoryOutput<Ctx>
where Ctx: Send,

§

impl<Ctx> Sync for InMemoryOutput<Ctx>
where Ctx: Sync,

§

impl<Ctx> Unpin for InMemoryOutput<Ctx>
where Ctx: Unpin,

§

impl<Ctx> UnwindSafe for InMemoryOutput<Ctx>
where Ctx: UnwindSafe,

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.