Trait StreamingHandler

Source
pub trait StreamingHandler {
    // Required method
    fn write_all(
        self: Box<Self>,
        sink: &mut StreamingHandlerSink<'_>,
    ) -> Result<(), Box<dyn StdError + Send + Sync>>;
}
Expand description

A callback used to write content asynchronously.

Use the streaming! macro to construct it.

Required Methods§

Source

fn write_all( self: Box<Self>, sink: &mut StreamingHandlerSink<'_>, ) -> Result<(), Box<dyn StdError + Send + Sync>>

This method is called only once, and is expected to write content by calling the sink.write_str() one or more times.

Multiple calls to sink.write_str() append more content to the output.

See StreamingHandlerSink.

Note: if you get “implementation of FnOnce is not general enough” error, add explicit argument sink: &mut StreamingHandlerSink<'_> to the closure.

Trait Implementations§

Source§

impl<F> From<F> for Box<dyn StreamingHandler + Send + 'static>
where F: FnOnce(&mut StreamingHandlerSink<'_>) -> Result<(), Box<dyn StdError + Send + Sync>> + Send + 'static,

Source§

fn from(f: F) -> Self

Converts to this type from the input type.

Implementors§

Source§

impl<F> StreamingHandler for F
where F: FnOnce(&mut StreamingHandlerSink<'_>) -> Result<(), Box<dyn StdError + Send + Sync>> + Send + 'static,