pub struct Producer { /* private fields */ }Expand description
Writes frames to a group in order.
Each group is delivered independently over a QUIC stream. Use Self::write_frame for simple single-buffer frames, or Self::create_frame for multi-chunk streaming writes.
Implementations§
Source§impl Producer
impl Producer
Sourcepub fn write_frame<B: IntoBytes>(
&mut self,
timestamp: Timestamp,
data: B,
) -> Result<()>
pub fn write_frame<B: IntoBytes>( &mut self, timestamp: Timestamp, data: B, ) -> Result<()>
A helper method to write a frame from a single byte buffer.
If you want to write multiple chunks, use Self::create_frame to get a frame producer. But an upfront size is required.
timestamp is converted into the parent track’s timescale. For data without
a presentation time, pass Timestamp::now explicitly.
Sourcepub fn create_frame(&mut self, frame: Info) -> Result<Producer<'_>>
pub fn create_frame(&mut self, frame: Info) -> Result<Producer<'_>>
Create a frame with an upfront size and presentation timestamp, streamed in
chunks. Borrows the group exclusively until the returned frame::Producer
is finished or dropped, so only one frame is open at a time.
The timestamp is converted into the parent track’s timescale, so the scale you
build it with doesn’t have to match the track. Returns Error::FrameTooLarge
if the declared size exceeds the group’s byte budget (refused before allocating)
or Error::TimestampMismatch if the timestamp can’t be converted (overflow).
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Return the number of frames written so far (completed plus any in-flight).
Sourcepub fn finish(&mut self) -> Result<()>
pub fn finish(&mut self) -> Result<()>
Mark the group as complete; no more frames will be written.
Borrows rather than consumes, so a later failure can still be reported through
abort. The handle also keeps the cached frames readable.
Sourcepub fn abort(self, err: Error) -> Result<()>
pub fn abort(self, err: Error) -> Result<()>
Abort the group with the given error.
Consumes the handle. Drops the cached frames so a stale Consumer can’t pin
their buffers in memory forever; consumers that haven’t drained yet surface the
abort error instead of the leftover cache.
Sourcepub fn poll_closed(&self, waiter: &Waiter) -> Poll<Error>
pub fn poll_closed(&self, waiter: &Waiter) -> Poll<Error>
Poll until the group is closed or aborted; ready with the cause.