pub struct TrackProducer { /* private fields */ }Expand description
A producer for a track, used to create new groups.
Implementations§
Source§impl TrackProducer
impl TrackProducer
Sourcepub fn new(info: Track) -> Self
pub fn new(info: Track) -> Self
Build a producer for the given track metadata. Prefer Track::produce.
Sourcepub fn create_group(&mut self, info: Group) -> Result<GroupProducer>
pub fn create_group(&mut self, info: Group) -> Result<GroupProducer>
Create a new group with the given sequence number.
Sourcepub fn append_group(&mut self) -> Result<GroupProducer>
pub fn append_group(&mut self) -> Result<GroupProducer>
Create a new group with the next sequence number.
Sourcepub fn write_frame<B: Into<Bytes>>(&mut self, frame: B) -> Result<()>
pub fn write_frame<B: Into<Bytes>>(&mut self, frame: B) -> Result<()>
Create a group with a single frame.
Sourcepub fn finish(&mut self) -> Result<()>
pub fn finish(&mut self) -> Result<()>
Mark the track as finished after the last appended group.
Sets the final sequence to one past the current max_sequence. No new groups at or above this sequence can be appended. NOTE: Old groups with lower sequence numbers can still arrive.
Sourcepub fn finish_at(&mut self, sequence: u64) -> Result<()>
pub fn finish_at(&mut self, sequence: u64) -> Result<()>
Mark the track as finished at an exact final sequence.
The caller must pass the current max_sequence exactly. Freezes the final boundary at one past the current max_sequence. No new groups at or above that sequence can be created. NOTE: Old groups with lower sequence numbers can still arrive.
Sourcepub fn abort(&mut self, err: Error) -> Result<()>
pub fn abort(&mut self, err: Error) -> Result<()>
Abort the track with the given error.
Drops the cached groups so a stale TrackConsumer can’t pin them (and
their frame buffers) in memory forever. Consumers that haven’t drained yet
surface the abort error instead of the leftover cache. Child groups are
independent: a consumer that already pulled a GroupConsumer keeps its
own handle and can finish reading it.
Sourcepub fn consume(&self) -> TrackConsumer
pub fn consume(&self) -> TrackConsumer
Create a new consumer for the track, starting at the beginning.
Sourcepub fn demand(&self) -> TrackDemand
pub fn demand(&self) -> TrackDemand
A cloneable watch-only handle to subscriber demand.