Output

Trait Output 

Source
pub trait Output {
    type Io<'o>: IoOutput<Error: Into<Self::Error>>
       where Self: 'o;
    type Ctx: Context;
    type Error;

    // Required methods
    async fn write(&mut self, value: &str) -> Result<(), Self::Error>;
    fn split(&mut self) -> (Self::Io<'_>, &Self::Ctx);
    fn context(&self) -> &Self::Ctx;

    // Provided method
    fn get_ctx<T>(&self) -> &T
       where Self::Ctx: ContextProvides<T> { ... }
}
Expand description

Code generation output. This is a high-level trait intended to represent wherever you’re writing to, with associated context. It can be split into that context in order to separate the I/O stream itself.

Required Associated Types§

Source

type Io<'o>: IoOutput<Error: Into<Self::Error>> where Self: 'o

The I/O stream type

Source

type Ctx: Context

The context holder

Source

type Error

The error type for write operations.

Required Methods§

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

Provided Methods§

Source

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

Gets a particular context value

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'o, O> Output for &'o mut O
where O: Output,

Source§

type Io<'b> = <O as Output>::Io<'b> where Self: 'b

Source§

type Ctx = <O as Output>::Ctx

Source§

type Error = <O as Output>::Error

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl<Ctx, Err> Output for InMemoryOutput<Ctx, Err>
where Ctx: Context, Err: From<Infallible>,

Source§

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

Source§

type Ctx = Ctx

Source§

type Error = Err

Source§

impl<I> Output for SimpleOutput<I>
where I: IoOutput,

Source§

type Io<'b> = &'b mut I where Self: 'b

Source§

type Ctx = DynContext

Source§

type Error = <I as IoOutput>::Error