binread::helpers

Function until_exclusive

source
pub fn until_exclusive<Reader, T, CondFn, Arg, Ret>(
    cond: CondFn,
) -> impl Fn(&mut Reader, &ReadOptions, Arg) -> BinResult<Ret>
where T: BinRead<Args = Arg>, Reader: Read + Seek, CondFn: Fn(&T) -> bool, Arg: Clone, Ret: FromIterator<T>,
Expand description

Read items until a condition is met. The last item will not be named.

ยงExamples

#[derive(BinRead)]
struct NullTerminated {
    #[br(parse_with = until_exclusive(|&byte| byte == 0))]
    data: Vec<u8>,
}