pub struct OriginProducer { /* private fields */ }Expand description
Announces broadcasts to consumers over the network.
Implementations§
Source§impl OriginProducer
impl OriginProducer
pub fn new() -> Self
Sourcepub fn create_broadcast(&self, path: impl AsPath) -> Option<BroadcastProducer>
pub fn create_broadcast(&self, path: impl AsPath) -> Option<BroadcastProducer>
Create and publish a new broadcast, returning the producer.
This is a helper method when you only want to publish a broadcast to a single origin. Returns None if the broadcast is not allowed to be published.
Sourcepub fn publish_broadcast(
&self,
path: impl AsPath,
broadcast: BroadcastConsumer,
) -> bool
pub fn publish_broadcast( &self, path: impl AsPath, broadcast: BroadcastConsumer, ) -> bool
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 the older broadcast remains active and the new one is queued as a backup (no reannounce is triggered). When the active broadcast closes, the oldest queued backup is promoted and reannounced. A queued backup that closes before it is promoted is silently dropped with no announcement.
Returns false if the broadcast is not allowed to be published.
Sourcepub fn publish_only(&self, prefixes: &[Path<'_>]) -> Option<OriginProducer>
pub fn publish_only(&self, prefixes: &[Path<'_>]) -> Option<OriginProducer>
Returns a new OriginProducer where all published broadcasts MUST match one of the prefixes.
Returns None if there are no legal prefixes.
Sourcepub fn consume(&self) -> OriginConsumer
pub fn consume(&self) -> OriginConsumer
Subscribe to all announced broadcasts.
Sourcepub fn consume_only(&self, prefixes: &[Path<'_>]) -> Option<OriginConsumer>
pub fn consume_only(&self, prefixes: &[Path<'_>]) -> Option<OriginConsumer>
Subscribe to all announced broadcasts matching the prefix.
Returns None if there are no legal prefixes.
Sourcepub fn consume_broadcast(&self, path: impl AsPath) -> Option<BroadcastConsumer>
pub fn consume_broadcast(&self, path: impl AsPath) -> Option<BroadcastConsumer>
Subscribe to a specific broadcast.
Returns None if the broadcast is not found.
Sourcepub fn with_root(&self, prefix: impl AsPath) -> Option<Self>
pub fn with_root(&self, prefix: impl AsPath) -> Option<Self>
Returns a new OriginProducer that automatically strips out the provided prefix.
Returns None if the provided root is not authorized; when publish_only was already used without a wildcard.
Sourcepub fn root(&self) -> &Path<'_>
pub fn root(&self) -> &Path<'_>
Returns the root that is automatically stripped from all paths.
pub fn allowed(&self) -> impl Iterator<Item = &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