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<'_>
impl Relay<'_>
Sourcepub fn create_permission(
&mut self,
now: Instant,
peer_addr: SocketAddr,
) -> Result<Option<TransactionId>>
pub fn create_permission( &mut self, now: Instant, 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.
Sourcepub fn send_to(
&mut self,
now: Instant,
p: &[u8],
peer_addr: SocketAddr,
) -> Result<()>
pub fn send_to( &mut self, now: Instant, 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.
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> 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
Mutably borrows from an owned value. Read more