#[must_use] pubfn hex(buf: impl AsRef<[u8]>) -> String { letmut ret = String::with_capacity(buf.as_ref().len() * 2); for b in buf.as_ref() {
write!(&mut ret, "{b:02x}").unwrap();
}
ret
}
#[must_use] pubfn hex_snip_middle(buf: impl AsRef<[u8]>) -> String { const SHOW_LEN: usize = 8; let buf = buf.as_ref(); if buf.len() <= SHOW_LEN * 2 {
hex_with_len(buf)
} else { letmut ret = String::with_capacity(SHOW_LEN * 2 + 16);
write!(&mut ret, "[{}]: ", buf.len()).unwrap(); for b in &buf[..SHOW_LEN] {
write!(&mut ret, "{b:02x}").unwrap();
}
ret.push_str(".."); for b in &buf[buf.len() - SHOW_LEN..] {
write!(&mut ret, "{b:02x}").unwrap();
}
ret
}
}
#[must_use] pubfn hex_with_len(buf: impl AsRef<[u8]>) -> String { let buf = buf.as_ref(); letmut ret = String::with_capacity(10 + buf.len() * 2);
write!(&mut ret, "[{}]: ", buf.len()).unwrap(); for b in buf {
write!(&mut ret, "{b:02x}").unwrap();
}
ret
}
#[must_use] pubconstfn const_max(a: usize, b: usize) -> usize {
[a, b][(a < b) as usize]
} #[must_use] pubconstfn const_min(a: usize, b: usize) -> usize {
[a, b][(a >= b) as usize]
}
#[derive(Debug, PartialEq, Eq, Copy, Clone, Enum)] /// Client or Server. pubenum Role {
Client,
Server,
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.