pub struct OriginProducer { /* private fields */ }Expand description
Announces broadcasts to consumers over the network.
Implementations§
Source§impl OriginProducer
impl OriginProducer
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 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.
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.
TODO: Don’t use overlapping prefixes or duplicates will be published.
Returns None if there are no legal prefixes.
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