pub struct Node {
pub channels: Vec<u16>,
pub ports: Vec<u16>,
pub timer: Instant,
pub lifetime: u64,
pub secret: Arc<[u8; 16]>,
pub username: String,
pub password: String,
}
Expand description
turn node session.
Fields§
§channels: Vec<u16>
§ports: Vec<u16>
§timer: Instant
§lifetime: u64
§secret: Arc<[u8; 16]>
§username: String
§password: String
Implementations§
Source§impl Node
impl Node
Sourcepub fn new(realm: &str, username: &str, password: &str) -> Self
pub fn new(realm: &str, username: &str, password: &str) -> Self
create node session.
node session from group number and long key.
Sourcepub fn set_lifetime(&mut self, delay: u32)
pub fn set_lifetime(&mut self, delay: u32)
set the lifetime of the node.
delay is to die after the specified second.
§Examples
use turn_rs::router::nodes::*;
let mut node = Node::new("test", "test", "test");
node.set_lifetime(0);
assert!(node.is_death());
node.set_lifetime(600);
assert!(!node.is_death());
Sourcepub fn is_death(&self) -> bool
pub fn is_death(&self) -> bool
whether the node is dead.
§Examples
use turn_rs::router::nodes::*;
let mut node = Node::new("test", "test", "test");
node.set_lifetime(0);
assert!(node.is_death());
node.set_lifetime(600);
assert!(!node.is_death());
Sourcepub fn get_secret(&self) -> Arc<[u8; 16]>
pub fn get_secret(&self) -> Arc<[u8; 16]>
get node the secret.
§Examples
use turn_rs::router::nodes::*;
let mut node = Node::new("test", "test", "test");
let secret = node.get_secret();
assert_eq!(
secret.as_slice(),
&[
174, 238, 187, 253, 117, 209, 73, 157, 36, 56, 143, 91, 155, 16,
224, 239
]
);
Sourcepub fn push_port(&mut self, port: u16)
pub fn push_port(&mut self, port: u16)
posh port in node.
§Examples
use turn_rs::router::nodes::*;
let mut node = Node::new("test", "test", "test");
node.push_port(43196);
assert_eq!(&node.ports, &[43196]);
Sourcepub fn push_channel(&mut self, channel: u16)
pub fn push_channel(&mut self, channel: u16)
push channel in node.
§Examples
use turn_rs::router::nodes::*;
let mut node = Node::new("test", "test", "test");
node.push_channel(0x4000);
assert_eq!(&node.channels, &[0x4000]);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
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