pub struct BroadcastDynamic { /* private fields */ }Expand description
Handles on-demand track creation for a broadcast.
When a consumer requests a track that doesn’t exist, a TrackProducer is created and queued for the dynamic producer to fulfill via Self::requested_track. Dropped when no longer needed; pending requests are automatically aborted.
Implementations§
Source§impl BroadcastDynamic
impl BroadcastDynamic
Sourcepub fn poll_requested_track(
&mut self,
waiter: &Waiter,
) -> Poll<Result<TrackProducer, Error>>
pub fn poll_requested_track( &mut self, waiter: &Waiter, ) -> Poll<Result<TrackProducer, Error>>
Poll for the next consumer-requested track, without blocking. The returned producer is preconfigured with the requested track’s name and priority.
Sourcepub async fn requested_track(&mut self) -> Result<TrackProducer, Error>
pub async fn requested_track(&mut self) -> Result<TrackProducer, Error>
Block until a consumer requests a track, returning its producer.
Sourcepub fn consume(&self) -> BroadcastConsumer
pub fn consume(&self) -> BroadcastConsumer
Create a consumer that can subscribe to tracks in this broadcast.
Sourcepub async fn closed(&self) -> Error
pub async fn closed(&self) -> Error
Block until the broadcast is closed or aborted, returning the cause.
Sourcepub fn abort(&mut self, err: Error) -> Result<(), Error>
pub fn abort(&mut self, err: Error) -> Result<(), Error>
Abort the broadcast with the given error.
Externally-owned tracks are independent and must be aborted separately; inserted tracks are referenced via weak handles. Pending dynamic track requests are owned by the broadcast and aborted here so consumers don’t stay stuck waiting on producers nobody will fulfill.