Skip to main content

TurnClientApi

Trait TurnClientApi 

Source
pub trait TurnClientApi: Debug + Send {
Show 19 methods // Required methods fn transport(&self) -> TransportType; fn local_addr(&self) -> SocketAddr; fn remote_addr(&self) -> SocketAddr; fn relayed_addresses( &self, ) -> impl Iterator<Item = (TransportType, SocketAddr)>; fn permissions( &self, transport: TransportType, relayed: SocketAddr, ) -> impl Iterator<Item = IpAddr>; fn delete(&mut self, now: Instant) -> Result<(), DeleteError>; fn create_permission( &mut self, transport: TransportType, peer_addr: IpAddr, now: Instant, ) -> Result<(), CreatePermissionError>; fn have_permission(&self, transport: TransportType, to: IpAddr) -> bool; fn bind_channel( &mut self, transport: TransportType, peer_addr: SocketAddr, now: Instant, ) -> Result<(), BindChannelError>; fn tcp_connect( &mut self, peer_addr: SocketAddr, now: Instant, ) -> Result<(), TcpConnectError>; fn allocated_tcp_socket( &mut self, id: u32, five_tuple: Socket5Tuple, peer_addr: SocketAddr, local_addr: Option<SocketAddr>, now: Instant, ) -> Result<(), TcpAllocateError>; fn tcp_closed( &mut self, local_addr: SocketAddr, remote_addr: SocketAddr, now: Instant, ); fn send_to<T>( &mut self, transport: TransportType, to: SocketAddr, data: T, now: Instant, ) -> Result<Option<TransmitBuild<DelayedMessageOrChannelSend<T>>>, SendError> where T: AsRef<[u8]> + Debug; fn recv<T>(&mut self, transmit: Transmit<T>, now: Instant) -> TurnRecvRet<T> where T: AsRef<[u8]> + Debug; fn poll_recv(&mut self, now: Instant) -> Option<TurnPeerData<Vec<u8>>>; fn poll(&mut self, now: Instant) -> TurnPollRet; fn poll_transmit(&mut self, now: Instant) -> Option<Transmit<Data<'static>>>; fn poll_event(&mut self) -> Option<TurnEvent>; fn protocol_error(&mut self);
}
Expand description

The public API of a TURN client.

Required Methods§

Source

fn transport(&self) -> TransportType

The transport of the connection to the TURN server.

Source

fn local_addr(&self) -> SocketAddr

The local address of this TURN client.

Source

fn remote_addr(&self) -> SocketAddr

The remote TURN server’s address.

Source

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

The list of allocated relayed addresses on the TURN server.

Source

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

The list of permissions available for the provided relayed address.

Source

fn delete(&mut self, now: Instant) -> Result<(), DeleteError>

Remove the allocation/s on the server.

Source

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

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

Source

fn have_permission(&self, transport: TransportType, to: IpAddr) -> bool

Whether the client currently has a permission installed for the provided transport and address.

Source

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

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

Source

fn tcp_connect( &mut self, peer_addr: SocketAddr, now: Instant, ) -> Result<(), TcpConnectError>

Attempt to connect to a peer from the TURN server using TCP.

Requires that a TCP allocation has been allocated on the TURN server.

Source

fn allocated_tcp_socket( &mut self, id: u32, five_tuple: Socket5Tuple, peer_addr: SocketAddr, local_addr: Option<SocketAddr>, now: Instant, ) -> Result<(), TcpAllocateError>

Indicate success (or failure) to create a socket for the specified server and peer address.

The values @id, @five_tuple, and @peer_addr must match the values provided in matching the TurnPollRet::AllocateTcpSocket.

Source

fn tcp_closed( &mut self, local_addr: SocketAddr, remote_addr: SocketAddr, now: Instant, )

Indicate that the TCP connection has been closed.

Source

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

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 may instruct the caller to send a message to the turn server.

Source

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

Provide received data to the TURN client for handling.

The return value outlines what to do with this data.

Source

fn poll_recv(&mut self, now: Instant) -> Option<TurnPeerData<Vec<u8>>>

Poll the client for any further received data.

Source

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

Poll the client for further progress.

Source

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

Poll for a packet to send.

Source

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

Poll for an event that has occurred.

Source

fn protocol_error(&mut self)

A higher layer has encountered an error and this client is no longer usable.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§