Function cuprate_epee_encoding::write_iterator

source ·
pub fn write_iterator<T, I, B>(iterator: I, w: &mut B) -> Result<()>
where T: EpeeValue, I: Iterator<Item = T> + ExactSizeIterator, B: BufMut,
Expand description

Write an Iterator of EpeeValues to w with write_varint.

This function:

It is used as the internal EpeeValue::write implementation of containers such as EpeeValue::<Vec<T>>::write.

§Errors

This will error if:

§Example

let t: u64 = 3;
let vec: Vec<u64> = vec![t, t];
let mut w = vec![];

let iter: std::vec::IntoIter<u64> = vec.into_iter();
cuprate_epee_encoding::write_iterator(iter, &mut w).unwrap();

assert_eq!(w.len(), 17);
assert_eq!(w[1..9], [3, 0, 0, 0, 0, 0, 0, 0]);
assert_eq!(w[9..], [3, 0, 0, 0, 0, 0, 0, 0]);