use std::{
io::{self, Read},
net::TcpStream,
time::Duration,
};
pub type Uid = [u8; UID_LEN];
const UID_LEN: usize = 64;
pub const DEFAULT_IP: [u8; 4] = [127, 0, 0, 1];
pub const DEFAULT_RW_TIMEOUT: Duration = Duration::from_secs(3);
pub fn cmp_uids(a: &Uid, b: &Uid) -> bool {
for i in 0..a.len() {
if a[i] != b[i] {
return false;
}
}
true
}
pub fn read_uid<T>(stream: &mut TcpStream) -> io::Result<T> where T: From<Uid> {
let mut buf = [0_u8; UID_LEN];
stream.read_exact(&mut buf)?;
Ok(buf.into())
}