Skip to main content

Module util

Module util 

Source
Expand description

Helpers for reading, validating, and sizing encoded values.

Functionsยง

at_least
Checks if the buffer has at least len bytes remaining. Returns an Error::EndOfBuffer if not.
at_least_items
Checks if the buffer has at least len * item_size bytes remaining, treating multiplication overflow as insufficient. Returns an Error::EndOfBuffer if not.
ensure_zeros
Ensures the next size bytes are all zeroes in the provided buffer, returning an Error otherwise.
max_items_size
Returns an upper bound on the encoded size of a Vec or other length-prefixed sequence of len items that each encode to at most item_size bytes, with the length prefix at its widest.
read_fixed_vec
Reads len values of a FixedSize type from the buffer into a vector.