Skip to main content

DataConnection

Struct DataConnection 

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

One client data connection of a TCP allocation: a second TCP (or TLS) connection to the TURN server that, once bound, carries one peer’s byte stream as it is (RFC 6062 §4.3 to §4.5).

Made by Relay::data_connection with the CONNECTION-ID of a Connect success response (Event::ConnectResponse) or of a ConnectionAttempt indication (Event::ConnectionAttempt). Sans-I/O: the application opens the connection, to Self::server_addr and from a local port of its own, and then

Closing the TCP connection ends the peer’s connection too (RFC 6062 §4.6). The allocation must be kept refreshed for as long as the data connection is wanted, which the Client that made it does on its control connection.

Implementations§

Source§

impl DataConnection

Source

pub fn server_addr(&self) -> SocketAddr

The server’s transport address: where the application opens this connection to, the same one the control connection goes to (RFC 6062 §4.3).

Source

pub fn local_addr(&self) -> SocketAddr

The local address the application said this connection is made from.

Source

pub fn connection_id(&self) -> ConnectionId

The CONNECTION-ID this connection binds.

Source

pub fn is_bound(&self) -> bool

Whether the server accepted the ConnectionBind, so the connection carries the peer’s bytes.

Source

pub fn send(&mut self, now: Instant, data: &[u8]) -> Result<()>

Queues data for the peer, as it is.

§Errors

Fails until the connection is bound, and after it failed or was closed.

Trait Implementations§

Source§

impl Protocol<TransportMessage<BytesMut>, TransportMessage<BytesMut>, ()> for DataConnection

Source§

type Rout = BytesMut

The peer’s bytes.

Source§

type Wout = TransportMessage<BytesMut>

Bytes for the TCP connection to the server.

Source§

fn handle_read(&mut self, msg: TaggedBytesMut) -> Result<()>

Takes the next chunk read from the TCP connection, whatever its boundaries.

Source§

fn handle_write(&mut self, msg: TaggedBytesMut) -> Result<()>

Queues msg.message for the peer, as it is. msg.transport is not looked at.

Source§

type Eout = DataConnectionEvent

Output event type Read more
Source§

type Error = Error

Error type for protocol operations
Source§

type Time = Instant

Time/Instant type for timeout handling Read more
Source§

fn poll_read(&mut self) -> Option<Self::Rout>

Poll for a processed read message. Read more
Source§

fn poll_write(&mut self) -> Option<Self::Wout>

Poll for a processed write message. Read more
Source§

fn poll_event(&mut self) -> Option<Self::Eout>

Poll for a generated event. Read more
Source§

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

Handle a timeout event. Read more
Source§

fn poll_timeout(&mut self) -> Option<Instant>

Poll for the next timeout deadline. Read more
Source§

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

Close the protocol. Read more
Source§

fn handle_event(&mut self, _evt: Ein) -> Result<(), Self::Error>

Handle a custom event. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for DataConnection

§

impl !UnwindSafe for DataConnection

§

impl Forget for DataConnection

§

impl Freeze for DataConnection

§

impl Move for DataConnection

§

impl Send for DataConnection
where Arc<dyn RTCCryptoProvider>: Send, RawVecInner: Send, Arc<Credential>: Send, BytesMut: Send, &'static str: Send, BoxRaw<Error>: Send, Repr: Send, BoxRaw<dyn Error + Sync + Send>: Send,

§

impl Sync for DataConnection
where Arc<dyn RTCCryptoProvider>: Sync, RawVecInner: Sync, Arc<Credential>: Sync, BytesMut: Sync, BoxRaw<Error>: Sync, Repr: Sync, BoxRaw<dyn Error + Sync + Send>: Sync,

§

impl Unpin for DataConnection
where Arc<dyn RTCCryptoProvider>: Unpin, *const u8 is !null: Unpin, Arc<Credential>: Unpin, *mut Shared: Unpin, &'static str: Unpin, Box<Error>: Unpin, *const () is !null: Unpin, &'static SimpleMessage: Unpin, *const Custom is !null: Unpin, Box<dyn Error + Sync + Send>: Unpin,

§

impl UnsafeUnpin for DataConnection

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 = !

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.