pub struct Publication { /* private fields */ }Expand description
A published broadcast.
The broadcast lives in the node’s route table: fill it through
broadcast, and every link whose peer may see it serves
that one broadcast, with no copy in between.
Cheap to clone. The publication stays until unpublish,
until its broadcast closes, or until the node shuts down. Dropping the
handles leaves it in place. unpublish_on_drop
ties it to a scope instead.
§Examples
use std::collections::BTreeSet;
use iroh_live_node::Audience;
let publication = node.publish("live/studio", Audience::Granted)?;
let _track = publication.broadcast().create_track("video", None).ok_or("the track exists")?;
// Narrow it to one peer, who then holds the only route to it.
let peers = n0_watcher::Watchable::new(BTreeSet::from([peer]));
publication.set_audience(Audience::Peers(peers));
println!("{}", publication.ticket());Implementations§
Source§impl Publication
impl Publication
Sourcepub fn ticket(&self) -> BroadcastTicket
pub fn ticket(&self) -> BroadcastTicket
Returns the ticket that names this publication.
It holds the node’s endpoint id and the path, and nothing about layouts.
Sourcepub fn broadcast(&self) -> &Producer
pub fn broadcast(&self) -> &Producer
Returns the broadcast to fill.
Tracks created here are what peers read. Closing it withdraws the publication.
Sourcepub async fn withdrawn(&self)
pub async fn withdrawn(&self)
Waits until the publication is withdrawn.
Cancellation safe: dropping the future loses nothing.
Sourcepub fn is_withdrawn(&self) -> bool
pub fn is_withdrawn(&self) -> bool
Reports whether the publication has been withdrawn.
Sourcepub fn set_audience(&self, audience: Audience)
pub fn set_audience(&self, audience: Audience)
Changes who may see the publication.
Takes effect on every live session at once: a peer that may no longer
see it loses the path, and what it reads there ends with
moq_net::Error::Unauthorized. Does nothing once withdrawn.
§Panics
Panics when called outside a Tokio runtime.
Sourcepub fn unpublish(&self)
pub fn unpublish(&self)
Withdraws the publication from every link and from the route table.
Peers lose the path, and what they read there ends with
moq_net::Error::Unauthorized. The broadcast stays open for whoever
holds it, unannounced.
Sourcepub fn unpublish_on_drop(self) -> UnpublishOnDrop
pub fn unpublish_on_drop(self) -> UnpublishOnDrop
Returns a guard that unpublishes the publication when it drops.
For a publication that belongs to a task: when the task ends or is
aborted, the path is free again, and a later publish there does not
fail with Error::Duplicate. The guard unpublishes even while other
clones of the publication live. UnpublishOnDrop::disarm gives the
publication back without unpublishing.
§Examples
use iroh_live_node::Audience;
let publication = node
.publish("live/results", Audience::Granted)?
.unpublish_on_drop();
let _track = publication.broadcast().create_track("result", None);
// Leaving the scope unpublishes `live/results`.Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Publication
impl !UnwindSafe for Publication
impl Freeze for Publication
impl Send for Publication
impl Sync for Publication
impl Unpin for Publication
impl UnsafeUnpin for Publication
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.