aboutsummaryrefslogtreecommitdiff
path: root/src/model.rs
diff options
context:
space:
mode:
authorHristo Venev <hristo@venev.name>2019-04-02 15:56:06 +0300
committerHristo Venev <hristo@venev.name>2019-04-02 15:57:45 +0300
commitb06338ec1d282a762440ad72c935717e404badca (patch)
treef6e441e97f7676e1acab6fc4ba72c3b875e97d9b /src/model.rs
parentc3269142f8d6c016ce8100b86fcae2031b145a9a (diff)
Reorg, sources have names.
Diffstat (limited to 'src/model.rs')
-rw-r--r--src/model.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/model.rs b/src/model.rs
index f8b76b5..bc800b2 100644
--- a/src/model.rs
+++ b/src/model.rs
@@ -2,13 +2,14 @@
//
// See COPYING.
-use crate::bin;
-use crate::ip::{Ipv4Addr, Ipv4Net, Ipv6Addr, Ipv6Net, NetParseError};
use base64;
use std::collections::HashMap;
use std::fmt;
use std::str::FromStr;
+mod ip;
+pub use ip::*;
+
pub type KeyParseError = base64::DecodeError;
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
@@ -142,7 +143,7 @@ impl serde::Serialize for Endpoint {
let mut buf = [0u8; 16 + 2];
let (buf_addr, buf_port) = mut_array_refs![&mut buf, 16, 2];
*buf_addr = self.address.octets();
- *buf_port = crate::bin::u16_to_be(self.port);
+ *buf_port = self.port.to_be_bytes();
ser.serialize_bytes(&buf)
}
}
@@ -171,7 +172,7 @@ impl<'de> serde::Deserialize<'de> for Endpoint {
let (buf_addr, buf_port) = array_refs![&buf, 16, 2];
Ok(Endpoint {
address: (*buf_addr).into(),
- port: bin::u16_from_be(*buf_port),
+ port: u16::from_be_bytes(*buf_port),
})
}
}