pub fn write_bytes<T: AsRef<[u8]>, B: BufMut>(t: T, w: &mut B) -> Result<()>Expand description
Write a byte array to w with write_varint.
This function:
- Writes the length of
t’s bytes intowusingwrite_varint - Writes
t’s bytes intow
It is used as the internal EpeeValue::write
implementation of byte-like containers such as:
§Errors
This will error if:
write_varintfailswdoes not have enough capacity
§Example
let t: [u8; 8] = [3, 0, 0, 0, 1, 0, 0, 0];
let mut w = vec![];
cuprate_epee_encoding::write_bytes(t, &mut w).unwrap();
assert_eq!(w.len(), 9); // length of bytes + bytes
assert_eq!(w[1..], t);