pub struct Producer { /* private fields */ }Expand description
Publishes a binary value over a track, one value per group.
Each update rolls a new group holding the whole value, so a consumer only ever
needs the newest group and older ones are dropped. For a log where every payload survives, use
stream instead.
Cheaply clonable: clones share one underlying track, like other MoQ producers.
Implementations§
Source§impl Producer
impl Producer
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 consume(&self) -> Subscriber
pub fn consume(&self) -> Subscriber
Create a subscriber for the underlying track.
Sourcepub fn is_used(&self) -> bool
pub fn is_used(&self) -> bool
Whether any consumer for the underlying track currently exists.
The demand signal for a producer serving on request: an unused track is cached state nobody is watching, safe to drop and recreate on the next request.
Sourcepub fn update(&mut self, payload: impl Into<Timed<Bytes>>) -> Result<usize>
pub fn update(&mut self, payload: impl Into<Timed<Bytes>>) -> Result<usize>
Publish a new value, superseding the previous one, and return the frame’s encoded size.
Unlike moq-json, an identical value is republished rather than
skipped: comparing two opaque blobs costs a full scan, and only the caller knows whether its
bytes changed.