pub struct Tag<Inner, T>(pub Refined<Inner, TagPred<T>>);
Expand description
Generic tag combinator that matches the input with a given value and discards it
e.g. Tag(Int::<u8>, 0)
matches the byte 0
; Tag(Bytes::<3>, &[1, 2, 3])
matches the
bytes [1, 2, 3]
Tuple Fields§
§0: Refined<Inner, TagPred<T>>
Implementations§
Trait Implementations§
Source§impl<'a, Inner> Combinator for Tag<Inner, &'a [u8]>where
Inner: for<'b> Combinator<Result<'b> = &'b [u8], Owned = Vec<u8>>,
<Inner as View>::V: SecureSpecCombinator<SpecResult = Seq<u8>>,
impl<'a, Inner> Combinator for Tag<Inner, &'a [u8]>where
Inner: for<'b> Combinator<Result<'b> = &'b [u8], Owned = Vec<u8>>,
<Inner as View>::V: SecureSpecCombinator<SpecResult = Seq<u8>>,
Source§type Owned = ()
type Owned = ()
The owned parsed type. This is currently a hack to avoid lifetime bindings in
SpecCombinator::SpecResult
, but it can be useful if we want to have functions that return owned values (e.g. Vec<T>
).Source§fn length(&self) -> Option<usize>
fn length(&self) -> Option<usize>
The length of the output buffer, if known.
This can be used to optimize serialization by pre-allocating the buffer.
Source§impl<Inner, const N: usize> Combinator for Tag<Inner, [u8; N]>where
<Inner as View>::V: SecureSpecCombinator<SpecResult = Seq<u8>>,
Inner: for<'b> Combinator<Result<'b> = &'b [u8], Owned = Vec<u8>>,
impl<Inner, const N: usize> Combinator for Tag<Inner, [u8; N]>where
<Inner as View>::V: SecureSpecCombinator<SpecResult = Seq<u8>>,
Inner: for<'b> Combinator<Result<'b> = &'b [u8], Owned = Vec<u8>>,
Source§type Owned = ()
type Owned = ()
The owned parsed type. This is currently a hack to avoid lifetime bindings in
SpecCombinator::SpecResult
, but it can be useful if we want to have functions that return owned values (e.g. Vec<T>
).Source§fn length(&self) -> Option<usize>
fn length(&self) -> Option<usize>
The length of the output buffer, if known.
This can be used to optimize serialization by pre-allocating the buffer.
Source§impl<Inner, T> Combinator for Tag<Inner, T>where
<Inner as View>::V: SecureSpecCombinator<SpecResult = <T as View>::V>,
Inner: for<'a> Combinator<Result<'a> = T, Owned = T>,
T: FromToBytes,
impl<Inner, T> Combinator for Tag<Inner, T>where
<Inner as View>::V: SecureSpecCombinator<SpecResult = <T as View>::V>,
Inner: for<'a> Combinator<Result<'a> = T, Owned = T>,
T: FromToBytes,
Source§type Owned = ()
type Owned = ()
The owned parsed type. This is currently a hack to avoid lifetime bindings in
SpecCombinator::SpecResult
, but it can be useful if we want to have functions that return owned values (e.g. Vec<T>
).Source§fn length(&self) -> Option<usize>
fn length(&self) -> Option<usize>
The length of the output buffer, if known.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse<'a>(
&self,
s: &'a [u8],
) -> Result<(usize, <Tag<Inner, T> as Combinator>::Result<'a>), ParseError>
fn parse<'a>( &self, s: &'a [u8], ) -> Result<(usize, <Tag<Inner, T> as Combinator>::Result<'a>), ParseError>
The parsing function.
Source§impl<Inner, T> SpecCombinator for Tag<Inner, T>where
Inner: SpecCombinator<SpecResult = T>,
impl<Inner, T> SpecCombinator for Tag<Inner, T>where
Inner: SpecCombinator<SpecResult = T>,
Source§type SpecResult = ()
type SpecResult = ()
The view of
Combinator::Result
.impl DisjointFrom<Tag<Bytes, Seq<u8>>> for Tag<Bytes, Seq<u8>>
impl<const N: usize> DisjointFrom<Tag<BytesN<N>, Seq<u8>>> for Tag<BytesN<N>, Seq<u8>>
impl DisjointFrom<Tag<U16, u16>> for Tag<U16, u16>
impl DisjointFrom<Tag<U32, u32>> for Tag<U32, u32>
impl DisjointFrom<Tag<U64, u64>> for Tag<U64, u64>
impl DisjointFrom<Tag<U8, u8>> for Tag<U8, u8>
impl<Inner, T> SecureSpecCombinator for Tag<Inner, T>where
Inner: SecureSpecCombinator<SpecResult = T>,
Auto Trait Implementations§
impl<Inner, T> Freeze for Tag<Inner, T>
impl<Inner, T> RefUnwindSafe for Tag<Inner, T>where
Inner: RefUnwindSafe,
T: RefUnwindSafe,
impl<Inner, T> Send for Tag<Inner, T>
impl<Inner, T> Sync for Tag<Inner, T>
impl<Inner, T> Unpin for Tag<Inner, T>
impl<Inner, T> UnwindSafe for Tag<Inner, T>where
Inner: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> From<T> for Twhere
T: View,
<T as View>::V: SpecFrom<<T as View>::V>,
impl<T> From<T> for Twhere
T: View,
<T as View>::V: SpecFrom<<T as View>::V>,
Source§fn ex_from(t: T) -> T
fn ex_from(t: T) -> T
Vest equivalent of
std::convert::From::from
.Source§impl<T, U> Into<U> for T
impl<T, U> Into<U> for T
Source§fn ex_into(self) -> U
fn ex_into(self) -> U
Vest equivalent of
std::convert::Into::into
.Source§impl<T, U> SpecTryInto<U> for Twhere
U: SpecTryFrom<T>,
impl<T, U> SpecTryInto<U> for Twhere
U: SpecTryFrom<T>,
Source§type Error = <U as SpecTryFrom<T>>::Error
type Error = <U as SpecTryFrom<T>>::Error
The type returned in the event of a conversion error.