pub struct OriginProducer { /* private fields */ }Expand description
Announces broadcasts to consumers over the network.
Implementations§
Source§impl OriginProducer
impl OriginProducer
Sourcepub fn new(info: Origin) -> Self
pub fn new(info: Origin) -> Self
Build a producer for the given origin id with no scoped prefix and no
pre-existing broadcasts. Prefer Origin::produce.
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, the new one replaces the active only if its hop path is shorter or equal; otherwise it is queued as a backup. When the active broadcast closes, the backup with the shortest hop path is promoted and reannounced. Backups that close before being promoted are silently dropped.
Returns false if the broadcast is not allowed to be published.
Sourcepub fn scope(&self, prefixes: &[Path<'_>]) -> Option<OriginProducer>
pub fn scope(&self, prefixes: &[Path<'_>]) -> Option<OriginProducer>
Returns a new OriginProducer restricted to publishing under one of prefixes.
Returns None if there are no legal prefixes (the requested prefixes are disjoint from this producer’s current scope).
Sourcepub fn consume(&self) -> OriginConsumer
pub fn consume(&self) -> OriginConsumer
Subscribe to all announced broadcasts.
Sourcepub fn get_broadcast(&self, path: impl AsPath) -> Option<BroadcastConsumer>
👎Deprecated: use consume().get_broadcast(path) once consume() is cheap
pub fn get_broadcast(&self, path: impl AsPath) -> Option<BroadcastConsumer>
use consume().get_broadcast(path) once consume() is cheap
Get a broadcast by path if it has already been published.
Equivalent to self.consume().get_broadcast(path) but skips the
announcement-cursor allocation, which is currently relatively expensive.
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 Self::scope
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.
Trait Implementations§
Source§impl Clone for OriginProducer
impl Clone for OriginProducer
Source§fn clone(&self) -> OriginProducer
fn clone(&self) -> OriginProducer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more