Trait esde::Sender

source ·
pub trait Sender {
    type Item;
    type Error: Error;

    // Required method
    fn get(&mut self) -> Result<Self::Item, Error<Self::Error>>;

    // Provided methods
    fn fill_buffer(
        &mut self,
        buffer: &mut [Self::Item]
    ) -> Result<(), Error<Self::Error>> { ... }
    fn get_buffer<const N: usize>(
        &mut self
    ) -> Result<[Self::Item; N], Error<Self::Error>> { ... }
    fn auto<D: Deserialize<Self::Item> + ?Sized>(
        &mut self
    ) -> Result<D, Error<Self::Error>> { ... }
    fn auto_de<D: Deserialize<Self::Item> + ?Sized>(
        &mut self
    ) -> Result<D, Error<Self::Error>> { ... }
}
Expand description

trait for an object than can send/supply some kind of Item

Required Associated Types§

source

type Item

the type of item supplied, e.g. u8s

source

type Error: Error

the type of error that can occur when an Item is requested

Required Methods§

source

fn get(&mut self) -> Result<Self::Item, Error<Self::Error>>

get the next item

Provided Methods§

source

fn fill_buffer( &mut self, buffer: &mut [Self::Item] ) -> Result<(), Error<Self::Error>>

fill a buffer of items (completely)

Note

The canonical implementation calls Self::get as often as necessary, throwing the corresponding errors. This function should be overloaded if a better implementation can be made.

source

fn get_buffer<const N: usize>( &mut self ) -> Result<[Self::Item; N], Error<Self::Error>>

get a buffer of N items that is completely filled

Note

The canonical implementation calls Self::get as often as necessary, throwing the corresponding errors. This function should be overloaded if a better implementation can be made.

source

fn auto<D: Deserialize<Self::Item> + ?Sized>( &mut self ) -> Result<D, Error<Self::Error>>

automatically parse the (usually inferred) output type that implements Deserialize

source

fn auto_de<D: Deserialize<Self::Item> + ?Sized>( &mut self ) -> Result<D, Error<Self::Error>>

alias for Self::auto to be used in cases when a type implements Sender and crate::Receiver

Implementors§

source§

impl<T: Read> Sender for T

any std::io::Read can send u8s

§

type Item = u8

§

type Error = Error