pub struct Nonces { /* private fields */ }
Expand description
nonce table.
Implementations§
Source§impl Nonces
impl Nonces
pub fn new() -> Self
Sourcepub fn get(&self, a: &SocketAddr) -> Arc<String>
pub fn get(&self, a: &SocketAddr) -> Arc<String>
get session nonce string.
each node is assigned a random string valid for 1 hour.
§Examples
use std::net::SocketAddr;
use turn_rs::router::nonces::*;
let addr = "127.0.0.1:1080".parse::<SocketAddr>().unwrap();
let nonce_table = Nonces::new();
assert_eq!(nonce_table.get(&addr).len(), 16);
Sourcepub fn remove(&self, a: &SocketAddr)
pub fn remove(&self, a: &SocketAddr)
remove session nonce string.
§Examples
use std::net::SocketAddr;
use turn_rs::router::nonces::*;
let addr = "127.0.0.1:1080".parse::<SocketAddr>().unwrap();
let nonce_table = Nonces::new();
let nonce = nonce_table.get(&addr);
nonce_table.remove(&addr);
let new_nonce = nonce_table.get(&addr);
assert!(nonce.as_str() != new_nonce.as_str());
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Nonces
impl RefUnwindSafe for Nonces
impl Send for Nonces
impl Sync for Nonces
impl Unpin for Nonces
impl UnwindSafe for Nonces
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