Skip to main content

Source

Trait Source 

Source
pub trait Source {
    type Item;
    type Error: StageError;

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

    // Provided method
    fn close(&mut self) -> Result<(), Self::Error> { ... }
}
Expand description

Producer at the head of a pipeline.

Required Associated Types§

Source

type Item

Type of item produced.

Source

type Error: StageError

Error type the source can return.

Required Methods§

Source

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

Pull the next item.

§Errors

Returns Err(Self::Error) if the source fails. The driver wraps this in crate::Error::Source.

Ok(None) signals end-of-stream.

Provided Methods§

Source

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

Close the source. Default impl does nothing.

§Errors

Returns Err(Self::Error) if cleanup fails.

Implementors§

Source§

impl<F, T, E> Source for FnSource<F, T, E>
where F: FnMut() -> Result<Option<T>, E>, E: StageError,

Source§

type Item = T

Source§

type Error = E

Source§

impl<I> Source for IterSource<I>
where I: Iterator,

Source§

impl<R: Read> Source for ReaderSource<R>

Available on crate feature std only.
Source§

impl<T> Source for ChannelSource<T>
where T: 'static,

Available on crate feature std only.