Struct Channel

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

Peer channels.

A channel binding consists of:

  • a channel number;

  • a transport address (of the peer); and

  • A time-to-expiry timer.

Within the context of an allocation, a channel binding is uniquely identified either by the channel number or by the peer’s transport address. Thus, the same channel cannot be bound to two different transport addresses, nor can the same transport address be bound to two different channels.

A channel binding lasts for 10 minutes unless refreshed. Refreshing the binding (by the server receiving a ChannelBind request rebinding the channel to the same peer) resets the time-to-expiry timer back to 10 minutes.

When the channel binding expires, the channel becomes unbound. Once unbound, the channel number can be bound to a different transport address, and the transport address can be bound to a different channel number. To prevent race conditions, the client MUST wait 5 minutes after the channel binding expires before attempting to bind the channel number to a different transport address or the transport address to a different channel number.

When binding a channel to a peer, the client SHOULD be prepared to receive ChannelData messages on the channel from the server as soon as it has sent the ChannelBind request. Over UDP, it is possible for the client to receive ChannelData messages from the server before it receives a ChannelBind success response.

In the other direction, the client MAY elect to send ChannelData messages before receiving the ChannelBind success response. Doing so, however, runs the risk of having the ChannelData messages dropped by the server if the ChannelBind request does not succeed for some reason (e.g., packet lost if the request is sent over UDP or the server being unable to fulfill the request). A client that wishes to be safe should either queue the data or use Send indications until the channel binding is confirmed.

Implementations§

Source§

impl Channel

Source

pub fn new(a: &SocketAddr) -> Self

Source

pub fn includes(&self, a: &SocketAddr) -> bool

whether to include the current socketaddr.

§Examples
use std::net::SocketAddr;
use turn_rs::router::channels::*;

let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let channel = Channel::new(&addr);
assert!(channel.includes(&addr));
Source

pub fn is_half(&self) -> bool

wether the peer addr has been established.

§Examples
use std::net::SocketAddr;
use turn_rs::router::channels::*;

let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let channel = Channel::new(&addr);
assert!(channel.is_half());
Source

pub fn up(&mut self, a: &SocketAddr)

update half addr.

§Examples
use std::net::SocketAddr;
use turn_rs::router::channels::*;

let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let peer = "127.0.0.1:8081".parse::<SocketAddr>().unwrap();
let mut channel = Channel::new(&addr);

channel.up(&peer);
assert!(!channel.is_half());
Source

pub fn refresh(&mut self)

refresh channel lifetime.

§Examples
use std::net::SocketAddr;
use turn_rs::router::channels::*;

let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let mut channel = Channel::new(&addr);

channel.refresh();
assert!(!channel.is_death());
Source

pub fn is_death(&self) -> bool

whether the channel lifetime has ended.

§Examples
use std::net::SocketAddr;
use turn_rs::router::channels::*;

let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let mut channel = Channel::new(&addr);
// channel.is_death()

Trait Implementations§

Source§

impl IntoIterator for Channel

Source§

fn into_iter(self) -> Self::IntoIter

Into iterator for channels.

§Examples
use std::net::SocketAddr;
use turn_rs::router::channels::*;

let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let channel = Channel::new(&addr);
let iter = channel.into_iter();
// iter.next()
Source§

type IntoIter = Iter

Which kind of iterator are we turning this into?
Source§

type Item = SocketAddr

The type of the elements being iterated over.

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, 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