pub struct OriginProducer { /* private fields */ }Expand description
Announces broadcasts to consumers over the network.
Implementations§
Source§impl OriginProducer
impl OriginProducer
Sourcepub fn new<T: Into<Path>>(prefix: T) -> Self
pub fn new<T: Into<Path>>(prefix: T) -> Self
Create a new origin producer with an optional prefix applied to all broadcasts.
Sourcepub fn publish<'a>(
&mut self,
suffix: impl Into<PathRef<'a>>,
broadcast: BroadcastConsumer,
)
pub fn publish<'a>( &mut self, suffix: impl Into<PathRef<'a>>, broadcast: BroadcastConsumer, )
Publish a broadcast, announcing it to all consumers.
The broadcast will be unannounced when it is closed. If there is already a broadcast with the same path, then it will be replaced and reannounced. If the old broadcast is closed before the new one, then nothing will happen. If the new broadcast is closed before the old one, then the old broadcast will be reannounced.
Sourcepub fn publish_prefix<'a>(
&mut self,
prefix: impl Into<PathRef<'a>>,
) -> OriginProducer
pub fn publish_prefix<'a>( &mut self, prefix: impl Into<PathRef<'a>>, ) -> OriginProducer
Create a new origin producer for the given sub-prefix.
Sourcepub fn consume<'a>(
&self,
suffix: impl Into<PathRef<'a>>,
) -> Option<BroadcastConsumer>
pub fn consume<'a>( &self, suffix: impl Into<PathRef<'a>>, ) -> Option<BroadcastConsumer>
Get a specific broadcast by path.
The most recent, non-closed broadcast will be returned if there are duplicates.
Sourcepub fn consume_all(&self) -> OriginConsumer
pub fn consume_all(&self) -> OriginConsumer
Subscribe to all announced broadcasts.
Sourcepub fn consume_prefix<'a>(
&self,
prefix: impl Into<PathRef<'a>>,
) -> OriginConsumer
pub fn consume_prefix<'a>( &self, prefix: impl Into<PathRef<'a>>, ) -> OriginConsumer
Subscribe to all announced broadcasts matching the prefix.
NOTE: This takes a Suffix because it’s appended to the existing prefix to get a new prefix. Confusing I know, but it means that we don’t have to return a Result.
Sourcepub async fn unused(&self)
pub async fn unused(&self)
Wait until all consumers have been dropped.
NOTE: subscribe can be called to unclose the producer.
pub fn prefix(&self) -> &Path
Trait Implementations§
Source§impl Clone for OriginProducer
impl Clone for OriginProducer
Source§fn clone(&self) -> OriginProducer
fn clone(&self) -> OriginProducer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more