pub trait SegmentSource {
// Required method
fn next_chunk(&mut self) -> Result<Option<Bytes>, Error>;
}Expand description
A source of exactly len value bytes for a streaming
set_stream, yielded in chunks.
The client pulls chunks with next_chunk until
it returns Ok(None) (exhausted), counting bytes as it goes. If the total
number of bytes yielded differs from the len passed to set_stream, the
send is a protocol desync and the connection is closed
(Error::LengthMismatch).
next_chunk is synchronous by design: it avoids the async_fn_in_trait
public-API lint and keeps v1 simple. A source backed by async I/O should
pre-buffer each chunk before yielding it. (An async pull is a documented
follow-up.)
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<I: Iterator<Item = Bytes>> SegmentSource for I
A SegmentSource that yields chunks from an in-memory iterator of
Bytes. Convenience for callers that already have their value in chunks
(or a single chunk); the streaming win is that ringline never gathers them
into one contiguous buffer.