Skip to main content

Relay

Struct Relay 

Source
pub struct Relay<'a> { /* private fields */ }
Expand description

A borrowed handle to one live allocation on the TURN server.

Obtained from Client::relay. Sending to a peer requires a permission for it first — see Self::create_permission.

Implementations§

Source§

impl Relay<'_>

Source

pub fn create_permission( &mut self, peer_addr: SocketAddr, ) -> Result<Option<TransactionId>>

Asks the server to permit traffic to and from peer_addr.

The relay silently drops data for peers with no permission, and permissions expire after five minutes unless refreshed. Returns the transaction id to match against the resulting Event, or None if a permission is already in place.

§Errors

Fails if the allocation no longer exists or the request cannot be encoded.

Source

pub fn send_to(&mut self, p: &[u8], peer_addr: SocketAddr) -> Result<()>

Sends p to peer_addr through the relay.

Uses ChannelData framing if a channel is bound for that peer, otherwise a Data indication.

§Errors

Fails if the allocation is gone, or if no permission exists for peer_addr.

Source

pub fn close(&mut self) -> Result<()>

Releases the allocation by refreshing it with a zero lifetime.

§Errors

Fails if the refresh request cannot be sent.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Relay<'a>

§

impl<'a> !UnwindSafe for Relay<'a>

§

impl<'a> Freeze for Relay<'a>

§

impl<'a> Send for Relay<'a>

§

impl<'a> Sync for Relay<'a>

§

impl<'a> Unpin for Relay<'a>

§

impl<'a> UnsafeUnpin for Relay<'a>

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<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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.