pub trait DekuWrite<Ctx = ()> {
// Required method
fn write(
&self,
output: &mut BitVec<u8, Msb0>,
ctx: Ctx
) -> Result<(), DekuError>;
}
Expand description
“Writer” trait: write from type to bits
Required Methods§
Implementations on Foreign Types§
source§impl DekuWrite<()> for NonZeroU128
impl DekuWrite<()> for NonZeroU128
source§impl DekuWrite<Endian> for NonZeroU64
impl DekuWrite<Endian> for NonZeroU64
source§impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>, E: DekuWrite<Ctx>, F: DekuWrite<Ctx>, G: DekuWrite<Ctx>, H: DekuWrite<Ctx>, I: DekuWrite<Ctx>, J: DekuWrite<Ctx>, K: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D, E, F, G, H, I, J, K)
impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>, E: DekuWrite<Ctx>, F: DekuWrite<Ctx>, G: DekuWrite<Ctx>, H: DekuWrite<Ctx>, I: DekuWrite<Ctx>, J: DekuWrite<Ctx>, K: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D, E, F, G, H, I, J, K)
source§impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C)
impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C)
source§impl DekuWrite<()> for NonZeroIsize
impl DekuWrite<()> for NonZeroIsize
source§impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>, E: DekuWrite<Ctx>, F: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D, E, F)
impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>, E: DekuWrite<Ctx>, F: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D, E, F)
source§impl DekuWrite<Endian> for NonZeroUsize
impl DekuWrite<Endian> for NonZeroUsize
source§impl DekuWrite<Endian> for NonZeroI16
impl DekuWrite<Endian> for NonZeroI16
source§impl DekuWrite<Endian> for NonZeroIsize
impl DekuWrite<Endian> for NonZeroIsize
source§impl DekuWrite<Endian> for NonZeroU128
impl DekuWrite<Endian> for NonZeroU128
source§impl DekuWrite<()> for NonZeroI128
impl DekuWrite<()> for NonZeroI128
source§impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D)
impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D)
source§impl DekuWrite<Endian> for NonZeroI32
impl DekuWrite<Endian> for NonZeroI32
source§impl DekuWrite<()> for NonZeroI32
impl DekuWrite<()> for NonZeroI32
source§impl<K: DekuWrite<Ctx>, V: DekuWrite<Ctx>, S, Ctx: Copy> DekuWrite<Ctx> for HashMap<K, V, S>
impl<K: DekuWrite<Ctx>, V: DekuWrite<Ctx>, S, Ctx: Copy> DekuWrite<Ctx> for HashMap<K, V, S>
source§fn write(
&self,
output: &mut BitVec<u8, Msb0>,
inner_ctx: Ctx
) -> Result<(), DekuError>
fn write( &self, output: &mut BitVec<u8, Msb0>, inner_ctx: Ctx ) -> Result<(), DekuError>
Write all K, V
s in a HashMap
to bits.
- inner_ctx - The context required by
K, V
. Note: depending on the HasherS
, the order in which theK, V
pairs are written may change between executions. Use a deterministic Hasher for your HashMap instead of the default RandomState hasher if you don’t want the order written to change.
Examples
let mut output = bitvec![u8, Msb0;];
let mut map = HashMap::<u8, u32>::default();
map.insert(100, 0x04030201);
map.write(&mut output, Endian::Big).unwrap();
let expected: Vec<u8> = vec![100, 4, 3, 2, 1];
assert_eq!(expected, output.into_vec())
source§impl DekuWrite<()> for NonZeroUsize
impl DekuWrite<()> for NonZeroUsize
source§impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>, E: DekuWrite<Ctx>, F: DekuWrite<Ctx>, G: DekuWrite<Ctx>, H: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D, E, F, G, H)
impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>, E: DekuWrite<Ctx>, F: DekuWrite<Ctx>, G: DekuWrite<Ctx>, H: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D, E, F, G, H)
source§impl<T, Ctx> DekuWrite<Ctx> for &Twhere
T: DekuWrite<Ctx>,
Ctx: Copy,
impl<T, Ctx> DekuWrite<Ctx> for &Twhere T: DekuWrite<Ctx>, Ctx: Copy,
Implements DekuWrite for references of types that implement DekuWrite
source§impl<T: DekuWrite<Ctx>, S, Ctx: Copy> DekuWrite<Ctx> for HashSet<T, S>
impl<T: DekuWrite<Ctx>, S, Ctx: Copy> DekuWrite<Ctx> for HashSet<T, S>
source§fn write(
&self,
output: &mut BitVec<u8, Msb0>,
inner_ctx: Ctx
) -> Result<(), DekuError>
fn write( &self, output: &mut BitVec<u8, Msb0>, inner_ctx: Ctx ) -> Result<(), DekuError>
Write all T
s in a HashSet
to bits.
- inner_ctx - The context required by
T
. Note: depending on the HasherS
, the order in which theT
’s are written may change between executions. Use a deterministic Hasher for your HashSet instead of the default RandomState hasher if you don’t want the order written to change.
Examples
let set: HashSet<u8> = vec![1].into_iter().collect();
let mut output = bitvec![u8, Msb0;];
set.write(&mut output, Endian::Big).unwrap();
assert_eq!(output, bitvec![u8, Msb0; 0, 0, 0, 0, 0, 0, 0, 1])
source§impl<T: DekuWrite<Ctx>, Ctx: Copy> DekuWrite<Ctx> for Vec<T>
impl<T: DekuWrite<Ctx>, Ctx: Copy> DekuWrite<Ctx> for Vec<T>
source§fn write(
&self,
output: &mut BitVec<u8, Msb0>,
inner_ctx: Ctx
) -> Result<(), DekuError>
fn write( &self, output: &mut BitVec<u8, Msb0>, inner_ctx: Ctx ) -> Result<(), DekuError>
Write all T
s in a Vec
to bits.
- inner_ctx - The context required by
T
.
Examples
let data = vec![1u8];
let mut output = bitvec![u8, Msb0;];
data.write(&mut output, Endian::Big).unwrap();
assert_eq!(output, bitvec![u8, Msb0; 0, 0, 0, 0, 0, 0, 0, 1])
source§impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>, E: DekuWrite<Ctx>, F: DekuWrite<Ctx>, G: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D, E, F, G)
impl<Ctx: Copy, A: DekuWrite<Ctx>, B: DekuWrite<Ctx>, C: DekuWrite<Ctx>, D: DekuWrite<Ctx>, E: DekuWrite<Ctx>, F: DekuWrite<Ctx>, G: DekuWrite<Ctx>> DekuWrite<Ctx> for (A, B, C, D, E, F, G)
source§impl DekuWrite<Endian> for NonZeroI64
impl DekuWrite<Endian> for NonZeroI64
source§impl<T: DekuWrite<Ctx>, Ctx: Copy> DekuWrite<Ctx> for Option<T>
impl<T: DekuWrite<Ctx>, Ctx: Copy> DekuWrite<Ctx> for Option<T>
source§fn write(
&self,
output: &mut BitVec<u8, Msb0>,
inner_ctx: Ctx
) -> Result<(), DekuError>
fn write( &self, output: &mut BitVec<u8, Msb0>, inner_ctx: Ctx ) -> Result<(), DekuError>
Write T if Some
- inner_ctx - The context required by
T
.
Examples
let data = Some(1u8);
let mut output = bitvec![u8, Msb0;];
data.write(&mut output, Endian::Big).unwrap();
assert_eq!(output, bitvec![u8, Msb0; 0, 0, 0, 0, 0, 0, 0, 1])