Skip to main content

barse/
wrap.rs

1//! For some [`crate::FromByteReaderWith`][FromByteReaderWith] implementations an implementation that is generic over a trait
2//! may be desired, this might lead to collisions, to remedy this newtype wrappers are used.
3
4/// Wrapper to allow [`FromByteReaderWith::from_byte_reader_with`][from_byte_reader_with]
5/// for vecs to take an iterator as input.
6#[derive(Default, Clone, Copy, PartialEq, PartialOrd, Ord, Eq, Debug, Hash)]
7pub struct Iter<I: IntoIterator>(pub I);
8
9/// Wrapper to allow [`FromByteReaderWith::from_byte_reader_with`][from_byte_reader_with]
10/// for vecs to take a length as input.
11#[derive(Default, Clone, Copy, PartialEq, PartialOrd, Ord, Eq, Debug, Hash)]
12pub struct Len(pub usize);
13
14/// Wrapper to allow a value to be specified as a callable allowing [`FromByteReaderWith`] to be
15/// implemented for all types.
16#[derive(Default, Clone, Copy, PartialEq, PartialOrd, Ord, Eq, Debug, Hash)]
17pub struct Fn<F>(pub F);
18
19/// Wrapper to allow a value to be carried forward or set to a value in a with impl.
20#[derive(Default, Clone, Copy, PartialEq, PartialOrd, Ord, Eq, Debug, Hash)]
21pub struct Value<T>(pub T);
22
23/// Wrapper to allow a value to be default initialized.
24#[derive(Default, Clone, Copy, PartialEq, PartialOrd, Ord, Eq, Debug, Hash)]
25pub struct Default;