pub struct Producer { /* private fields */ }Expand description
Writes the payload of a group’s single in-flight frame in one or more chunks.
Created by group::Producer::create_frame, which hands it the group’s writer: no
other frame can be opened, and the group cannot finish, until Self::finish returns
the writer. Owned rather than borrowed, so a driver can hold it across polls while
the payload streams in. Self::group still reads the group meanwhile.
The total bytes written must exactly match Info::size; call Self::finish to
commit the frame (or Self::abort to fail it). Dropping it without either aborts
the group, since an unfinished frame leaves the group’s stream broken.
A single whole-frame write keeps the caller’s allocation
(zero-copy). Chunked writes copy into one buffer, or a chain of fixed-size segments
for a large frame, each allocated whole by its first byte, or grown as bytes arrive
once the frames in flight pass the origin’s budget. Nothing is allocated past the
segment being written, whatever size was declared.
Implementations§
Source§impl Producer
impl Producer
Sourcepub fn group(&self) -> &Producer
pub fn group(&self) -> &Producer
The group this frame belongs to, readable while the frame holds its writer.
Sourcepub fn write<B: IntoBytes>(&mut self, chunk: B) -> Result<()>
pub fn write<B: IntoBytes>(&mut self, chunk: B) -> Result<()>
Write a chunk of data to the frame, waking its readers.
Returns Error::WrongSize if the chunk would exceed the remaining bytes.
Sourcepub fn finish(self) -> Result<Producer>
pub fn finish(self) -> Result<Producer>
Commit the frame, verifying that all bytes were written, and return the group’s writer for its next frame or its finish.
Returns Error::WrongSize if the bytes written don’t match Info::size.