Struct TurnClient

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

A TURN client.

Implementations§

Source§

impl TurnClient

Source

pub fn allocate( ttype: TransportType, local_addr: SocketAddr, remote_addr: SocketAddr, credentials: TurnCredentials, ) -> Self

Allocate an address on a TURN server to relay data to and from peers.

§Examples
let credentials = TurnCredentials::new("tuser", "tpass");
let transport = TransportType::Udp;
let local_addr = "192.168.0.1:4000".parse().unwrap();
let remote_addr = "10.0.0.1:3478".parse().unwrap();
let client = TurnClient::allocate(transport, local_addr, remote_addr, credentials);
assert_eq!(client.transport(), transport);
assert_eq!(client.local_addr(), local_addr);
assert_eq!(client.remote_addr(), remote_addr);
Source

pub fn transport(&self) -> TransportType

The transport of the connection to the TURN server.

Source

pub fn local_addr(&self) -> SocketAddr

The local address of this TURN client.

Source

pub fn remote_addr(&self) -> SocketAddr

The remote TURN server’s address.

Source

pub fn poll(&mut self, now: Instant) -> TurnPollRet

Poll the client for further progress.

Source

pub fn relayed_addresses( &self, ) -> impl Iterator<Item = (TransportType, SocketAddr)> + '_

The list of allocated relayed addresses on the TURN server.

Source

pub fn permissions( &self, transport: TransportType, relayed: SocketAddr, ) -> impl Iterator<Item = IpAddr> + '_

The list of permissions available for the provided relayed address.

Source

pub fn poll_transmit(&mut self, now: Instant) -> Option<Transmit<Data<'static>>>

Poll for a packet to send.

Source

pub fn poll_event(&mut self) -> Option<TurnEvent>

Poll for an event that has occurred.

Source

pub fn recv<T: AsRef<[u8]> + Debug>( &mut self, transmit: Transmit<T>, now: Instant, ) -> TurnRecvRet<T>

Provide received data to the TURN client for handling.

The returned data outlines what to do with this data.

Source

pub fn delete(&mut self, now: Instant) -> Option<Transmit<Data<'static>>>

Remove the allocation/s on the server.

Source

pub fn create_permission( &mut self, transport: TransportType, peer_addr: IpAddr, now: Instant, ) -> Result<Transmit<Data<'static>>, CreatePermissionError>

Create a permission address to allow sending/receiving data to/from.

Source

pub fn bind_channel( &mut self, transport: TransportType, peer_addr: SocketAddr, now: Instant, ) -> Result<Transmit<Data<'static>>, BindChannelError>

Bind a channel for sending/receiving data to/from a particular peer.

Source

pub fn send_to<T: AsRef<[u8]> + Debug>( &mut self, transport: TransportType, to: SocketAddr, data: T, now: Instant, ) -> Result<TransmitBuild<DelayedMessageOrChannelSend<T>>, StunError>

Send data to a peer through the TURN server.

The provided transport, address and data are the data to send to the peer.

The returned value will instruct the caller to send a message to the turn server.

Trait Implementations§

Source§

impl Debug for TurnClient

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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<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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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