pub struct Producer<T> { /* private fields */ }Expand description
Publishes a sliding window of JSON records over a track.
An Encoder that owns its track: it writes each encoded frame and rolls a group whenever the
encoder emits a header. When something else already owns the track, use the Encoder directly.
Cheaply clonable: clones share one underlying track and window, like other MoQ producers.
Implementations§
Source§impl<T> Producer<T>
impl<T> Producer<T>
Sourcepub fn new(track: Producer, config: ProducerConfig) -> Self
pub fn new(track: Producer, config: ProducerConfig) -> Self
Create a producer that publishes to the given track.
Sourcepub fn consume(&self) -> Subscriber
pub fn consume(&self) -> Subscriber
Create a subscriber for the underlying track.
Sourcepub fn window(&self) -> Vec<Value>
pub fn window(&self) -> Vec<Value>
The retained checkpoint suffix, oldest first.
This is the complete window unless ProducerConfig::checkpoint_records is set.
Sourcepub fn range(&self) -> Range<u64> ⓘ
pub fn range(&self) -> Range<u64> ⓘ
Absolute index of the oldest retained record, and of the next to be pushed.
Sourcepub fn pop(&mut self, count: u64) -> Result<()>
pub fn pop(&mut self, count: u64) -> Result<()>
Drop count records from the front of the window.
A no-op when the window is already empty, and clamped to what it holds, so a caller can trim unconditionally.
Sourcepub fn finish(&mut self) -> Result<()>
pub fn finish(&mut self) -> Result<()>
Finish the track, closing any open group.
Borrows rather than consumes, matching snapshot and stream, so the handle stays
usable afterwards (reads, a second finish). Writes after this fail with
moq_net::Error::Closed.