pub struct TrackConsumer {
pub info: Track,
/* private fields */
}Expand description
A consumer for a track, used to read groups.
Fields§
§info: TrackImplementations§
Source§impl TrackConsumer
impl TrackConsumer
Sourcepub fn poll_next_group(
&mut self,
waiter: &Waiter,
) -> Poll<Result<Option<GroupConsumer>>>
pub fn poll_next_group( &mut self, waiter: &Waiter, ) -> Poll<Result<Option<GroupConsumer>>>
Poll for the next group without blocking.
Returns Poll::Ready(Ok(Some(group))) when a group is available,
Poll::Ready(Ok(None)) when the track is finished,
Poll::Ready(Err(e)) when the track has been aborted, or
Poll::Pending when no group is available yet.
Sourcepub async fn next_group(&mut self) -> Result<Option<GroupConsumer>>
pub async fn next_group(&mut self) -> Result<Option<GroupConsumer>>
Return the next group in order.
NOTE: This can have gaps if the reader is too slow or there were network slowdowns.
Sourcepub fn poll_get_group(
&self,
waiter: &Waiter,
sequence: u64,
) -> Poll<Result<Option<GroupConsumer>>>
pub fn poll_get_group( &self, waiter: &Waiter, sequence: u64, ) -> Poll<Result<Option<GroupConsumer>>>
Poll for the group with the given sequence, without blocking.
Sourcepub async fn get_group(&self, sequence: u64) -> Result<Option<GroupConsumer>>
pub async fn get_group(&self, sequence: u64) -> Result<Option<GroupConsumer>>
Block until the group with the given sequence is available.
Returns None if the group is not in the cache and a newer group exists.
Sourcepub fn poll_closed(&self, waiter: &Waiter) -> Poll<Result<()>>
pub fn poll_closed(&self, waiter: &Waiter) -> Poll<Result<()>>
Poll for track closure, without blocking.
Sourcepub async fn closed(&self) -> Result<()>
pub async fn closed(&self) -> Result<()>
Block until the track is closed.
Returns Ok() is the track was cleanly finished.
pub fn is_clone(&self, other: &Self) -> bool
Sourcepub fn poll_finished(&mut self, waiter: &Waiter) -> Poll<Result<u64>>
pub fn poll_finished(&mut self, waiter: &Waiter) -> Poll<Result<u64>>
Poll for the total number of groups in the track.
Sourcepub async fn finished(&mut self) -> Result<u64>
pub async fn finished(&mut self) -> Result<u64>
Block until the track is finished, returning the total number of groups.
Sourcepub fn produce(&self) -> Result<TrackProducer>
pub fn produce(&self) -> Result<TrackProducer>
Upgrade this consumer back to a TrackProducer sharing the same state.
This enables zero-copy track sharing between broadcasts: subscribe to a
track, then crate::BroadcastProducer::insert_track the producer into another
broadcast. Both broadcasts serve the same underlying track data with no
forwarding overhead.
§Shared Ownership
The returned producer shares state with the original track. Mutations (appending groups, finishing, aborting) through either producer affect all consumers of the track. The returned producer keeps the track alive (prevents auto-close) as long as it exists, even if the original producer is dropped.
Trait Implementations§
Source§impl Clone for TrackConsumer
impl Clone for TrackConsumer
Source§fn clone(&self) -> TrackConsumer
fn clone(&self) -> TrackConsumer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more