pub struct Channels { /* private fields */ }
Expand description
channels table.
Implementations§
Source§impl Channels
impl Channels
pub fn new() -> Self
Sourcepub fn get_bound(&self, a: &SocketAddr, c: u16) -> Option<SocketAddr>
pub fn get_bound(&self, a: &SocketAddr, c: u16) -> Option<SocketAddr>
get bound address.
§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 channels = Channels::new();
channels.insert(&addr, 43159, &peer).unwrap();
channels.insert(&peer, 43160, &addr).unwrap();
assert_eq!(channels.get_bound(&addr, 43159).unwrap(), peer);
Sourcepub fn insert(&self, a: &SocketAddr, c: u16, p: &SocketAddr) -> Option<()>
pub fn insert(&self, a: &SocketAddr, c: u16, p: &SocketAddr) -> Option<()>
insert address for peer address to channel table.
§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 channels = Channels::new();
channels.insert(&addr, 43159, &peer).unwrap();
channels.insert(&peer, 43160, &addr).unwrap();
assert_eq!(channels.get_bound(&addr, 43159).unwrap(), peer);
Sourcepub fn remove(&self, c: u16) -> Option<()>
pub fn remove(&self, c: u16) -> Option<()>
remove channel allocate in channel table.
§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 channels = Channels::new();
channels.insert(&addr, 43159, &peer).unwrap();
channels.insert(&peer, 43160, &addr).unwrap();
assert!(channels.remove(43159).is_some());
assert!(channels.remove(43160).is_some());
Sourcepub fn get_deaths(&self) -> Vec<u16>
pub fn get_deaths(&self) -> Vec<u16>
get death channels.
use turn_rs::router::channels::*;
let channels = Channels::new();
assert_eq!(channels.get_deaths().len(), 0);
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Channels
impl RefUnwindSafe for Channels
impl Send for Channels
impl Sync for Channels
impl Unpin for Channels
impl UnwindSafe for Channels
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