Function binrw::helpers::until_eof_with
source · pub fn until_eof_with<Reader, T, Arg, ReadFn, Ret>(
read: ReadFn,
) -> impl Fn(&mut Reader, Endian, Arg) -> BinResult<Ret>where
Reader: Read + Seek,
Arg: Clone,
ReadFn: Fn(&mut Reader, Endian, Arg) -> BinResult<T>,
Ret: FromIterator<T>,
Expand description
Creates a parser that uses a given function to read items into a collection until the end of the input stream.
The given read
function should return one item each time it is called.
This helper can be used to read into any collection type that implements
FromIterator
.
§Errors
If reading fails for a reason other than reaching the end of the input, an
Error
variant will be returned.
§Examples
Reading a two-dimensional VecDeque
by combining until_eof_with
and
count
:
#[derive(BinRead)]
struct EntireFile {
#[br(parse_with = until_eof_with(count(2)))]
data: VecDeque<VecDeque<u8>>,
}