pub struct Interfaces { /* private fields */ }
Implementations§
Source§impl Interfaces
impl Interfaces
Sourcepub fn insert(
&self,
addr: SocketAddr,
interface: SocketAddr,
external: SocketAddr,
)
pub fn insert( &self, addr: SocketAddr, interface: SocketAddr, external: SocketAddr, )
add interface from addr.
§Examples
use std::net::SocketAddr;
use turn_rs::router::interfaces::*;
let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let interface = "127.0.0.1:8081".parse::<SocketAddr>().unwrap();
let interfaces = Interfaces::default();
interfaces.insert(addr, interface, interface);
let ret = interfaces.get(&addr).unwrap();
assert_eq!(ret.addr, interface);
assert_eq!(ret.external, interface);
Sourcepub fn get(&self, addr: &SocketAddr) -> Option<Interface>
pub fn get(&self, addr: &SocketAddr) -> Option<Interface>
get interface from addr.
§Examples
use std::net::SocketAddr;
use turn_rs::router::interfaces::*;
let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let interface = "127.0.0.1:8081".parse::<SocketAddr>().unwrap();
let interfaces = Interfaces::default();
interfaces.insert(addr, interface, interface);
let ret = interfaces.get(&addr).unwrap();
assert_eq!(ret.addr, interface);
assert_eq!(ret.external, interface);
Sourcepub fn get_ref(&self, addr: &SocketAddr) -> Option<Arc<Interface>>
pub fn get_ref(&self, addr: &SocketAddr) -> Option<Arc<Interface>>
get interface ref from addr.
§Examples
use std::net::SocketAddr;
use std::sync::Arc;
use turn_rs::router::interfaces::*;
let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let interface = "127.0.0.1:8081".parse::<SocketAddr>().unwrap();
let interfaces = Interfaces::default();
interfaces.insert(addr, interface, interface);
let ret = interfaces.get_ref(&addr).unwrap();
assert_eq!(ret.addr, interface);
assert_eq!(ret.external, interface);
Sourcepub fn remove(&self, addr: &SocketAddr)
pub fn remove(&self, addr: &SocketAddr)
remove interface from addr.
§Examples
use std::net::SocketAddr;
use std::sync::Arc;
use turn_rs::router::interfaces::*;
let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let interface = "127.0.0.1:8081".parse::<SocketAddr>().unwrap();
let interfaces = Interfaces::default();
interfaces.insert(addr, interface, interface);
let ret = interfaces.get(&addr).unwrap();
assert_eq!(ret.addr, interface);
assert_eq!(ret.external, interface);
interfaces.remove(&addr);
let ret = interfaces.get(&addr);
assert!(ret.is_none());
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Interfaces
impl RefUnwindSafe for Interfaces
impl Send for Interfaces
impl Sync for Interfaces
impl Unpin for Interfaces
impl UnwindSafe for Interfaces
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