pub struct OriginConsumer { /* private fields */ }Expand description
Consumes announced broadcasts matching against an optional prefix.
NOTE: Clone is expensive, try to avoid it.
Implementations§
Source§impl OriginConsumer
impl OriginConsumer
Sourcepub async fn announced(&mut self) -> Option<OriginAnnounce>
pub async fn announced(&mut self) -> Option<OriginAnnounce>
Returns the next (un)announced broadcast and the absolute path.
The broadcast will only be announced if it was previously unannounced. The same path won’t be announced/unannounced twice, instead it will toggle. Returns None if the consumer is closed.
Note: The returned path is absolute and will always match this consumer’s prefix.
Sourcepub fn try_announced(&mut self) -> Option<OriginAnnounce>
pub fn try_announced(&mut self) -> Option<OriginAnnounce>
Returns the next (un)announced broadcast and the absolute path without blocking.
Returns None if there is no update available; NOT because the consumer is closed.
You have to use is_closed to check if the consumer is closed.
pub fn consume(&self) -> Self
Sourcepub fn consume_broadcast(&self, path: impl AsPath) -> Option<BroadcastConsumer>
pub fn consume_broadcast(&self, path: impl AsPath) -> Option<BroadcastConsumer>
Get a specific broadcast by path.
TODO This should include announcement support.
Returns None if the path hasn’t been announced yet.
Sourcepub fn consume_only(&self, prefixes: &[Path<'_>]) -> Option<OriginConsumer>
pub fn consume_only(&self, prefixes: &[Path<'_>]) -> Option<OriginConsumer>
Returns a new OriginConsumer that only consumes broadcasts matching one of the prefixes.
Returns None if there are no legal prefixes (would always return None).
Sourcepub fn with_root(&self, prefix: impl AsPath) -> Option<Self>
pub fn with_root(&self, prefix: impl AsPath) -> Option<Self>
Returns a new OriginConsumer that automatically strips out the provided prefix.
Returns None if the provided root is not authorized; when consume_only was already used without a wildcard.
Sourcepub fn root(&self) -> &Path<'_>
pub fn root(&self) -> &Path<'_>
Returns the prefix that is automatically stripped from all paths.