mirror of https://github.com/dswd/vpncloud.git
Using copy trait more often
This commit is contained in:
parent
b6449484e5
commit
4b68923f75
|
@ -75,7 +75,7 @@ impl Table for SwitchTable {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn learn(&mut self, key: Address, _prefix_len: Option<u8>, addr: SocketAddr) {
|
fn learn(&mut self, key: Address, _prefix_len: Option<u8>, addr: SocketAddr) {
|
||||||
let value = SwitchTableValue{address: addr, timeout: now()+self.timeout as Time};
|
let value = SwitchTableValue{address: addr, timeout: now()+self.timeout as Time};
|
||||||
if self.table.insert(key.clone(), value).is_none() {
|
if self.table.insert(key, value).is_none() {
|
||||||
info!("Learned address {} => {}", key, addr);
|
info!("Learned address {} => {}", key, addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub type NetworkId = u64;
|
||||||
pub type NodeId = [u8; NODE_ID_BYTES];
|
pub type NodeId = [u8; NODE_ID_BYTES];
|
||||||
|
|
||||||
|
|
||||||
#[derive(PartialOrd, Eq, Ord, Clone, Hash)]
|
#[derive(PartialOrd, Eq, Ord, Clone, Hash, Copy)]
|
||||||
pub struct Address {
|
pub struct Address {
|
||||||
pub data: [u8; 16],
|
pub data: [u8; 16],
|
||||||
pub len: u8
|
pub len: u8
|
||||||
|
@ -128,7 +128,7 @@ impl FromStr for Address {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone)]
|
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, Copy)]
|
||||||
pub struct Range {
|
pub struct Range {
|
||||||
pub base: Address,
|
pub base: Address,
|
||||||
pub prefix_len: u8
|
pub prefix_len: u8
|
||||||
|
@ -196,7 +196,7 @@ impl fmt::Display for Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(RustcDecodable, Debug)]
|
#[derive(RustcDecodable, Debug, Clone, Copy)]
|
||||||
pub enum Mode {
|
pub enum Mode {
|
||||||
Normal, Hub, Switch, Router
|
Normal, Hub, Switch, Router
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub const VERSION: u8 = 1;
|
||||||
|
|
||||||
const NETWORK_ID_BYTES: usize = 8;
|
const NETWORK_ID_BYTES: usize = 8;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Copy)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
struct TopHeader {
|
struct TopHeader {
|
||||||
magic: [u8; 3],
|
magic: [u8; 3],
|
||||||
|
|
Loading…
Reference in New Issue