CliInput

Trait CliInput 

Source
pub trait CliInput {
    type Error: Debug;

    // Required method
    fn read_line<'io, 'buf>(
        &'io mut self,
        buf: &'buf mut [u8],
    ) -> impl Future<Output = Result<Option<&'buf str>, Self::Error>> + 'io
       where 'buf: 'io;
}
Expand description

Line-reading half of the CLI transport.

Read futures returned by CliInput::read_line are NOT required to be cancellation-safe. The driver keeps each read future alive across multiple wake events and only drops it when it completes, so implementations may safely park partial-line state inside the returned future.

Required Associated Types§

Required Methods§

Source

fn read_line<'io, 'buf>( &'io mut self, buf: &'buf mut [u8], ) -> impl Future<Output = Result<Option<&'buf str>, Self::Error>> + 'io
where 'buf: 'io,

Read one line (terminator stripped) into buf. Ok(None) on EOF. Err on overflow (line > buf.len()) or invalid UTF-8.

The returned &'buf str borrows from buf only, not from self.

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.

Implementors§