1 mod hex; 2 mod thread_id; 3 4 pub use hex::*; 5 pub use thread_id::*; 6 7 /// Lightweight wrapper around `&[u8]` which denotes that the contained data is 8 /// a ASCII string. 9 #[derive(Debug)] 10 #[repr(transparent)] 11 pub struct Bstr<'a>(&'a [u8]); 12 13 impl<'a> From<&'a [u8]> for Bstr<'a> { from(s: &'a [u8]) -> Bstr<'a>14 fn from(s: &'a [u8]) -> Bstr<'a> { 15 Bstr(s) 16 } 17 } 18 19 impl<'a> From<Bstr<'a>> for &'a [u8] { from(s: Bstr<'a>) -> &'a [u8]20 fn from(s: Bstr<'a>) -> &'a [u8] { 21 s.0 22 } 23 } 24 25 impl AsRef<[u8]> for Bstr<'_> { as_ref(&self) -> &[u8]26 fn as_ref(&self) -> &[u8] { 27 self.0 28 } 29 } 30