pub struct Pulls { /* private fields */ }Expand description
The media relay’s pulls, shared by every session that names a ticket.
Cheap to clone. Each pull runs in a task that the clones own together, so dropping the last clone ends every pull.
§Examples
use iroh_live_node::BroadcastTicket;
use iroh_live_relay::pull::{Client, Pulls, mounted};
let pulls = Pulls::new(endpoint, cluster.clone());
if let Ok(ticket) = requested.parse::<BroadcastTicket>() {
// Hold the guard while the session that asked runs.
let _guard = pulls.pull(Client::Unknown, requested, &ticket).await?;
let _view = mounted(&cluster, requested);
}Implementations§
Source§impl Pulls
impl Pulls
Sourcepub fn new(endpoint: Endpoint, cluster: Cluster) -> Self
pub fn new(endpoint: Endpoint, cluster: Cluster) -> Self
Creates the pulls of a media relay, which dial over endpoint into cluster.
§Panics
Panics when called outside a Tokio runtime.
Sourcepub fn with_access(self, access: Access) -> Self
pub fn with_access(self, access: Access) -> Self
Sets which sessions may pull, which defaults to Access::Authorized.
Sourcepub fn with_limits(self, limits: Limits) -> Self
pub fn with_limits(self, limits: Limits) -> Self
Sets the bounds on pulls, which default to Limits::default.
Sourcepub fn with_linger(self, linger: Duration) -> Self
pub fn with_linger(self, linger: Duration) -> Self
Sets how long an unused pull stays connected.
Defaults to ten seconds, long enough for a page reload to reuse the connection.
Sourcepub async fn pull(
&self,
client: Client,
requested: &str,
ticket: &BroadcastTicket,
) -> Result<PullGuard, Error>
pub async fn pull( &self, client: Client, requested: &str, ticket: &BroadcastTicket, ) -> Result<PullGuard, Error>
Pulls the broadcast ticket names into the cluster, and waits for it to connect.
The pull is for a session of client that asked for requested.
Hold the returned PullGuard while that session runs, and serve it
the cluster mounted at requested. Concurrent pulls of one name
share a dial. It does not check Access.
Cancellation safe: dropping this future only drops the caller’s hold. The dial runs on, and the pull retires as usual.
§Errors
Fails as start does, then with Error::Claim if
the ticket’s peer does not own its path, Error::Connect or
Error::Subscribe if the publisher cannot be reached or refuses the
path, and Error::Timeout if it does not announce the broadcast
within 15 seconds.
Sourcepub fn start(
&self,
client: Client,
requested: &str,
ticket: &BroadcastTicket,
) -> Result<PullGuard, Error>
pub fn start( &self, client: Client, requested: &str, ticket: &BroadcastTicket, ) -> Result<PullGuard, Error>
Starts pulling the broadcast ticket names, or joins the pull of requested.
Returns at once with the hold, before the dial connects: await
PullGuard::connected for its outcome. The Limits are checked
here, so a session that exceeds them can be refused before it starts.
It does not check Access.
§Errors
Fails with Error::ClientPullLimit if client already holds
Limits::per_client pulls. A new dial also fails with
Error::PullLimit if the media relay holds Limits::total pulls, and
with Error::DialRateLimit if client has used up its dials.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Pulls
impl !UnwindSafe for Pulls
impl Freeze for Pulls
impl Send for Pulls
impl Sync for Pulls
impl Unpin for Pulls
impl UnsafeUnpin for Pulls
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more