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_recv_group(
&mut self,
waiter: &Waiter,
) -> Poll<Result<Option<GroupConsumer>>>
pub fn poll_recv_group( &mut self, waiter: &Waiter, ) -> Poll<Result<Option<GroupConsumer>>>
Poll for the next group received over the network, in arrival order, without blocking.
Groups may arrive out of order or with gaps due to network conditions.
Use Self::next_group_ordered if you need groups in sequence order,
skipping those that arrive too late.
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 recv_group(&mut self) -> Result<Option<GroupConsumer>>
pub async fn recv_group(&mut self) -> Result<Option<GroupConsumer>>
Receive the next group available on this track, in arrival order.
Groups may arrive out of order or with gaps due to network conditions.
Use Self::next_group_ordered if you need groups in sequence order,
skipping those that arrive too late.
Sourcepub fn poll_next_group(
&mut self,
waiter: &Waiter,
) -> Poll<Result<Option<GroupConsumer>>>
👎Deprecated: use poll_recv_group for arrival order, or poll_next_group_ordered for sequence order
pub fn poll_next_group( &mut self, waiter: &Waiter, ) -> Poll<Result<Option<GroupConsumer>>>
use poll_recv_group for arrival order, or poll_next_group_ordered for sequence order
Deprecated alias for Self::poll_recv_group.
Sourcepub async fn next_group(&mut self) -> Result<Option<GroupConsumer>>
👎Deprecated: use recv_group for arrival order, or next_group_ordered for sequence order
pub async fn next_group(&mut self) -> Result<Option<GroupConsumer>>
use recv_group for arrival order, or next_group_ordered for sequence order
Deprecated alias for Self::recv_group.
Sourcepub fn poll_next_group_ordered(
&mut self,
waiter: &Waiter,
) -> Poll<Result<Option<GroupConsumer>>>
pub fn poll_next_group_ordered( &mut self, waiter: &Waiter, ) -> Poll<Result<Option<GroupConsumer>>>
A helper that calls Self::poll_recv_group but only returns groups with a sequence number higher than any previously returned.
NOTE: This will be renamed to poll_next_group in the next major version.
Sourcepub async fn next_group_ordered(&mut self) -> Result<Option<GroupConsumer>>
pub async fn next_group_ordered(&mut self) -> Result<Option<GroupConsumer>>
Return the next group with a strictly-greater sequence number than the last returned.
Groups that arrive late (with a sequence number at or below the last one returned) are silently skipped.
NOTE: This will be renamed to next_group in the next major version.
Sourcepub fn poll_read_frame(
&mut self,
waiter: &Waiter,
) -> Poll<Result<Option<Bytes>>>
pub fn poll_read_frame( &mut self, waiter: &Waiter, ) -> Poll<Result<Option<Bytes>>>
A helper that calls Self::poll_next_group_ordered and returns its first frame,
skipping the rest of the group. Intended for single-frame groups (see
TrackProducer::write_frame).
Sourcepub async fn read_frame(&mut self) -> Result<Option<Bytes>>
pub async fn read_frame(&mut self) -> Result<Option<Bytes>>
Read a single full frame from the next group in sequence order.
See Self::poll_read_frame for semantics.
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