use std::{
io::{self, Read},
mem,
time::Duration,
};
pub type Id = [u8; 64];
pub const DEFAULT_IP: [u8; 4] = [127, 0, 0, 1];
pub const DEFAULT_RW_TIMEOUT: Duration = Duration::from_secs(3);
pub fn cmp_ids(a: &Id, b: &Id) -> bool {
for i in 0..a.len() {
if a[i] != b[i] {
return false;
}
}
true
}
pub fn read_id<T>(stream: &mut Read) -> io::Result<T> where T: From<Id> {
let mut buf = [0_u8; mem::size_of::<Id>()];
stream.read_exact(&mut buf)?;
Ok(buf.into())
}
#[test]
fn test_id() {
assert_eq!(mem::size_of::<Id>(), 64);
}