Skip to main content

Calls

Struct Calls 

Source
pub struct Calls { /* private fields */ }
Expand description

The call service of a node.

Cheap to clone. See the module for the protocol.

§Examples

use iroh_live::{calls::Calls, layout::LiveLayout};
use moq_net::broadcast;

let (calls, side): (Calls, broadcast::Producer) = Calls::new(&node, &LiveLayout::default())?;
let call = calls.call(peer).await?;
// Fill `side` with tracks and read the peer's side from the call.

Implementations§

Source§

impl Calls

Source

pub fn new<B>(node: &Node, layout: &LiveLayout) -> Result<(Self, B), Error>
where B: TryFrom<Producer, Error: Error + Send + Sync + 'static>,

Publishes this node’s call side at <root>/<its id>/call and starts the service.

Returns the service with the side, which is visible to nobody until a peer is rung. One side serves every call in turn, so a camera and a preview keep running between calls. B is built from the route table’s broadcast::Producer before the path is announced: a LocalBroadcast, or the producer itself.

For a LocalBroadcast, dropping the side ends every call and closed resolves. A bare producer has to be closed by the application.

Each node’s policy has to let the other publish at <root>/<peer id>/call, as LiveLayout::policy does. Otherwise call and answer fail with NotGranted.

§Errors

Fails with Error::Node if the side is already published or B cannot be built.

§Panics

Panics when called outside a Tokio runtime.

Source

pub fn ring(&self, peer: EndpointId)

Rings peer: offers it this node’s side, and dials it if no session exists.

Non-blocking and idempotent. The peer sees the side appear in its route table.

§Panics

Panics when called outside a Tokio runtime.

Source

pub async fn call(&self, peer: EndpointId) -> Result<Call, Error>

Calls peer: rings it, waits until it answers, and subscribes to its side.

Waits as long as the peer takes to answer, so bound it with a timeout. Dropping the future hangs up.

§Errors

Fails with Error::AlreadyInCall if a call with peer exists, Error::NotAnswered if the session ends first, and Error::Node otherwise, holding NotGranted if the session’s grant does not let the peer publish its side.

Source

pub async fn answer(&self, peer: EndpointId) -> Result<Call, Error>

Answers the call of peer: rings it back, and subscribes to its side.

Dropping the future hangs up.

§Errors

Fails with Error::NotRinging if peer is not calling, and as call otherwise.

Source

pub fn ringing(&self) -> Direct<BTreeSet<EndpointId>>

Returns the peers that ring this node now, as they change.

These are the peers whose side is visible, in no call, and not hung up on since they last offered their side. A peer leaves the set when it withdraws its side before an answer, and when this node answers or calls it. Call::ended reports how a call in progress ends.

Source

pub fn ticket(&self) -> BroadcastTicket

Returns the ticket a peer calls this node with.

It names this node’s side, <root>/<its id>/call. A peer passes its peer to call.

Source

pub async fn next_ring(&self) -> Option<EndpointId>

Waits until a peer rings, and returns the first that does.

Returns a peer that rings already at once. Returns None once the service ends. Cancellation safe.

Source

pub async fn closed(&self)

Waits until the service ends: the node shut down, or the call side was withdrawn.

Cancellation safe.

Trait Implementations§

Source§

impl Clone for Calls

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Calls

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Calls

§

impl !UnwindSafe for Calls

§

impl Freeze for Calls

§

impl Send for Calls

§

impl Sync for Calls

§

impl Unpin for Calls

§

impl UnsafeUnpin for Calls

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more