pub struct Producer<T> { /* private fields */ }Expand description
Publishes an ordered log of JSON records over a track, one record per frame in a single group.
An Encoder that owns its track. When something else already owns the track, use the
Encoder directly.
Cheaply clonable: clones share one underlying track and publishing state, so multiple owners (e.g. several producers feeding one log) append into a single ordered stream.
finish or abort a complete or failed log. Dropping the last
clone unfinished closes the track cleanly while nobody reads it, so an on-demand publisher drops
it once its demand goes idle. Once it published, a
reader still reading reads [moq_net::Error::Dropped] instead of being handed to the track’s
next producer, which could not continue the log (see
[moq_net::track::Producer::abandon]).
Implementations§
Source§impl<T> Producer<T>
impl<T> Producer<T>
Source§impl<T: Serialize> Producer<T>
impl<T: Serialize> Producer<T>
Sourcepub fn new(track: Producer, config: Config) -> Self
pub fn new(track: Producer, config: Config) -> Self
Create a producer that publishes to the given track.
Sourcepub fn append(&mut self, value: &T, at: Timestamp) -> Result<usize>
pub fn append(&mut self, value: &T, at: Timestamp) -> Result<usize>
Append one record to the log at at (see Timed::at).
The log accepts appends for its track’s life. A record larger than a frame may be is refused
with [moq_net::Error::FrameTooLarge] before anything is written, leaving the log intact. A
timestamp that doesn’t match the track’s timescale (unscaled on a timed track, scaled on a
scale-less one, or beyond what its scale can hold) is refused with
[moq_net::Error::TimestampMismatch] the same way, so a corrected append carries on.
Any other failure ends the track. A log missing a record is not the lossless log a stream promises, and that holds whether the group rejected the record or it never encoded at all, so the failure is surfaced rather than papered over with a second group. The track is aborted rather than closed cleanly, so a consumer sees the failure instead of a log that merely looks complete. Every later append fails on the ended track.
Returns the encoded size of the frame written.