pub struct Vector;
Expand description
Namespace for functions that perform encoding of vectors.
The length of a vector is restricted to at most 0x02000000
, for compatibility with
the Zcash consensus rules.
Implementations§
Source§impl Vector
impl Vector
Sourcepub fn read<R: Read, E, F>(reader: R, func: F) -> Result<Vec<E>>
pub fn read<R: Read, E, F>(reader: R, func: F) -> Result<Vec<E>>
Reads a vector, assuming the encoding written by Vector::write
, using the provided
function to decode each element of the vector.
Sourcepub fn read_collected<R: Read, E, F, O: FromIterator<E>>(
reader: R,
func: F,
) -> Result<O>
pub fn read_collected<R: Read, E, F, O: FromIterator<E>>( reader: R, func: F, ) -> Result<O>
Reads a CompactSize-prefixed series of elements into a collection, assuming the encoding
written by Vector::write
, using the provided function to decode each element.
Sourcepub fn read_collected_mut<R: Read, E, F, O: FromIterator<E>>(
reader: R,
func: F,
) -> Result<O>
pub fn read_collected_mut<R: Read, E, F, O: FromIterator<E>>( reader: R, func: F, ) -> Result<O>
Reads a CompactSize-prefixed series of elements into a collection, assuming the encoding
written by Vector::write
, using the provided function to decode each element.
Sourcepub fn write<W: Write, E, F>(writer: W, vec: &[E], func: F) -> Result<()>
pub fn write<W: Write, E, F>(writer: W, vec: &[E], func: F) -> Result<()>
Writes a slice of values by writing CompactSize
-encoded integer specifying the length
of the slice to the stream, followed by the encoding of each element of the slice as
performed by the provided function.
Sourcepub fn write_nonempty<W: Write, E, F>(
writer: W,
vec: &NonEmpty<E>,
func: F,
) -> Result<()>
pub fn write_nonempty<W: Write, E, F>( writer: W, vec: &NonEmpty<E>, func: F, ) -> Result<()>
Writes a NonEmpty container of values to the stream using the same encoding as
[Vector::write]
Sourcepub fn write_sized<W: Write, E, F, I: Iterator<Item = E> + ExactSizeIterator>(
writer: W,
items: I,
func: F,
) -> Result<()>
pub fn write_sized<W: Write, E, F, I: Iterator<Item = E> + ExactSizeIterator>( writer: W, items: I, func: F, ) -> Result<()>
Writes an iterator of values by writing CompactSize
-encoded integer specifying
the length of the iterator to the stream, followed by the encoding of each element
of the iterator as performed by the provided function.
Sourcepub fn serialized_size_of_u8_vec(vec: &[u8]) -> usize
pub fn serialized_size_of_u8_vec(vec: &[u8]) -> usize
Returns the serialized size of a vector of u8
as written by [Vector::write]
.