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(U8, 0) matches the byte 0; Tag(Fixed::<3>, &[1, 2, 3]) matches the
bytes [1, 2, 3]
Tuple Fields§
§0: Refined<Inner, TagPred<T>>Implementations§
Trait Implementations§
Source§impl<'x, const N: usize> Combinator<'x, &'x [u8], Vec<u8>> for Tag<Fixed<N>, [u8; N]>
impl<'x, const N: usize> Combinator<'x, &'x [u8], Vec<u8>> for Tag<Fixed<N>, [u8; N]>
Source§type SType = ()
type SType = ()
The input type of serialization, often a reference to
Self::Type.
For “structural” formats though (e.g., crate::regular::sequence::Pair and crate::regular::variant::Choice),
this is the tuple/sum of the corresponding Combinator::SType types.Source§fn length(&self, _v: Self::SType) -> usize
fn length(&self, _v: Self::SType) -> usize
The length of the output buffer.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse(&self, s: &'x [u8]) -> Result<(usize, Self::Type), ParseError>
fn parse(&self, s: &'x [u8]) -> Result<(usize, Self::Type), ParseError>
The parsing function.
To enable “zero-copy” parsing, implementations of
parse should not
consume/deepcopy the input buffer I, but rather return a slice of the
input buffer for Self::Type whenever possible.
See crate::buf_traits::VestInput and crate::buf_traits::VestPublicInput for
more details. Read moreSource§fn serialize(
&self,
v: Self::SType,
data: &mut Vec<u8>,
pos: usize,
) -> Result<usize, SerializeError>
fn serialize( &self, v: Self::SType, data: &mut Vec<u8>, pos: usize, ) -> Result<usize, SerializeError>
The serialization function.
The intended use of
serialize is to serialize a value v into the
buffer buf at the position pos “in-place” (i.e., without
allocating a new buffer or extending the buffer). Read moreSource§impl<'x, I, O> Combinator<'x, I, O> for Tag<U16Be, u16>where
I: VestPublicInput,
O: VestPublicOutput<I>,
impl<'x, I, O> Combinator<'x, I, O> for Tag<U16Be, u16>where
I: VestPublicInput,
O: VestPublicOutput<I>,
Source§type SType = ()
type SType = ()
The input type of serialization, often a reference to
Self::Type.
For “structural” formats though (e.g., crate::regular::sequence::Pair and crate::regular::variant::Choice),
this is the tuple/sum of the corresponding Combinator::SType types.Source§fn length(&self, v: Self::SType) -> usize
fn length(&self, v: Self::SType) -> usize
The length of the output buffer.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
The parsing function.
To enable “zero-copy” parsing, implementations of
parse should not
consume/deepcopy the input buffer I, but rather return a slice of the
input buffer for Self::Type whenever possible.
See crate::buf_traits::VestInput and crate::buf_traits::VestPublicInput for
more details. Read moreSource§fn serialize(
&self,
v: Self::SType,
data: &mut O,
pos: usize,
) -> Result<usize, SerializeError>
fn serialize( &self, v: Self::SType, data: &mut O, pos: usize, ) -> Result<usize, SerializeError>
The serialization function.
The intended use of
serialize is to serialize a value v into the
buffer buf at the position pos “in-place” (i.e., without
allocating a new buffer or extending the buffer). Read moreSource§impl<'x, I, O> Combinator<'x, I, O> for Tag<U16Le, u16>where
I: VestPublicInput,
O: VestPublicOutput<I>,
impl<'x, I, O> Combinator<'x, I, O> for Tag<U16Le, u16>where
I: VestPublicInput,
O: VestPublicOutput<I>,
Source§type SType = ()
type SType = ()
The input type of serialization, often a reference to
Self::Type.
For “structural” formats though (e.g., crate::regular::sequence::Pair and crate::regular::variant::Choice),
this is the tuple/sum of the corresponding Combinator::SType types.Source§fn length(&self, v: Self::SType) -> usize
fn length(&self, v: Self::SType) -> usize
The length of the output buffer.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
The parsing function.
To enable “zero-copy” parsing, implementations of
parse should not
consume/deepcopy the input buffer I, but rather return a slice of the
input buffer for Self::Type whenever possible.
See crate::buf_traits::VestInput and crate::buf_traits::VestPublicInput for
more details. Read moreSource§fn serialize(
&self,
v: Self::SType,
data: &mut O,
pos: usize,
) -> Result<usize, SerializeError>
fn serialize( &self, v: Self::SType, data: &mut O, pos: usize, ) -> Result<usize, SerializeError>
The serialization function.
The intended use of
serialize is to serialize a value v into the
buffer buf at the position pos “in-place” (i.e., without
allocating a new buffer or extending the buffer). Read moreSource§impl<'x, I, O> Combinator<'x, I, O> for Tag<U32Be, u32>where
I: VestPublicInput,
O: VestPublicOutput<I>,
impl<'x, I, O> Combinator<'x, I, O> for Tag<U32Be, u32>where
I: VestPublicInput,
O: VestPublicOutput<I>,
Source§type SType = ()
type SType = ()
The input type of serialization, often a reference to
Self::Type.
For “structural” formats though (e.g., crate::regular::sequence::Pair and crate::regular::variant::Choice),
this is the tuple/sum of the corresponding Combinator::SType types.Source§fn length(&self, v: Self::SType) -> usize
fn length(&self, v: Self::SType) -> usize
The length of the output buffer.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
The parsing function.
To enable “zero-copy” parsing, implementations of
parse should not
consume/deepcopy the input buffer I, but rather return a slice of the
input buffer for Self::Type whenever possible.
See crate::buf_traits::VestInput and crate::buf_traits::VestPublicInput for
more details. Read moreSource§fn serialize(
&self,
v: Self::SType,
data: &mut O,
pos: usize,
) -> Result<usize, SerializeError>
fn serialize( &self, v: Self::SType, data: &mut O, pos: usize, ) -> Result<usize, SerializeError>
The serialization function.
The intended use of
serialize is to serialize a value v into the
buffer buf at the position pos “in-place” (i.e., without
allocating a new buffer or extending the buffer). Read moreSource§impl<'x, I, O> Combinator<'x, I, O> for Tag<U32Le, u32>where
I: VestPublicInput,
O: VestPublicOutput<I>,
impl<'x, I, O> Combinator<'x, I, O> for Tag<U32Le, u32>where
I: VestPublicInput,
O: VestPublicOutput<I>,
Source§type SType = ()
type SType = ()
The input type of serialization, often a reference to
Self::Type.
For “structural” formats though (e.g., crate::regular::sequence::Pair and crate::regular::variant::Choice),
this is the tuple/sum of the corresponding Combinator::SType types.Source§fn length(&self, v: Self::SType) -> usize
fn length(&self, v: Self::SType) -> usize
The length of the output buffer.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
The parsing function.
To enable “zero-copy” parsing, implementations of
parse should not
consume/deepcopy the input buffer I, but rather return a slice of the
input buffer for Self::Type whenever possible.
See crate::buf_traits::VestInput and crate::buf_traits::VestPublicInput for
more details. Read moreSource§fn serialize(
&self,
v: Self::SType,
data: &mut O,
pos: usize,
) -> Result<usize, SerializeError>
fn serialize( &self, v: Self::SType, data: &mut O, pos: usize, ) -> Result<usize, SerializeError>
The serialization function.
The intended use of
serialize is to serialize a value v into the
buffer buf at the position pos “in-place” (i.e., without
allocating a new buffer or extending the buffer). Read moreSource§impl<'x, I, O> Combinator<'x, I, O> for Tag<U64Be, u64>where
I: VestPublicInput,
O: VestPublicOutput<I>,
impl<'x, I, O> Combinator<'x, I, O> for Tag<U64Be, u64>where
I: VestPublicInput,
O: VestPublicOutput<I>,
Source§type SType = ()
type SType = ()
The input type of serialization, often a reference to
Self::Type.
For “structural” formats though (e.g., crate::regular::sequence::Pair and crate::regular::variant::Choice),
this is the tuple/sum of the corresponding Combinator::SType types.Source§fn length(&self, v: Self::SType) -> usize
fn length(&self, v: Self::SType) -> usize
The length of the output buffer.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
The parsing function.
To enable “zero-copy” parsing, implementations of
parse should not
consume/deepcopy the input buffer I, but rather return a slice of the
input buffer for Self::Type whenever possible.
See crate::buf_traits::VestInput and crate::buf_traits::VestPublicInput for
more details. Read moreSource§fn serialize(
&self,
v: Self::SType,
data: &mut O,
pos: usize,
) -> Result<usize, SerializeError>
fn serialize( &self, v: Self::SType, data: &mut O, pos: usize, ) -> Result<usize, SerializeError>
The serialization function.
The intended use of
serialize is to serialize a value v into the
buffer buf at the position pos “in-place” (i.e., without
allocating a new buffer or extending the buffer). Read moreSource§impl<'x, I, O> Combinator<'x, I, O> for Tag<U64Le, u64>where
I: VestPublicInput,
O: VestPublicOutput<I>,
impl<'x, I, O> Combinator<'x, I, O> for Tag<U64Le, u64>where
I: VestPublicInput,
O: VestPublicOutput<I>,
Source§type SType = ()
type SType = ()
The input type of serialization, often a reference to
Self::Type.
For “structural” formats though (e.g., crate::regular::sequence::Pair and crate::regular::variant::Choice),
this is the tuple/sum of the corresponding Combinator::SType types.Source§fn length(&self, v: Self::SType) -> usize
fn length(&self, v: Self::SType) -> usize
The length of the output buffer.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
The parsing function.
To enable “zero-copy” parsing, implementations of
parse should not
consume/deepcopy the input buffer I, but rather return a slice of the
input buffer for Self::Type whenever possible.
See crate::buf_traits::VestInput and crate::buf_traits::VestPublicInput for
more details. Read moreSource§fn serialize(
&self,
v: Self::SType,
data: &mut O,
pos: usize,
) -> Result<usize, SerializeError>
fn serialize( &self, v: Self::SType, data: &mut O, pos: usize, ) -> Result<usize, SerializeError>
The serialization function.
The intended use of
serialize is to serialize a value v into the
buffer buf at the position pos “in-place” (i.e., without
allocating a new buffer or extending the buffer). Read moreSource§impl<'x, I, O> Combinator<'x, I, O> for Tag<U8, u8>where
I: VestPublicInput,
O: VestPublicOutput<I>,
impl<'x, I, O> Combinator<'x, I, O> for Tag<U8, u8>where
I: VestPublicInput,
O: VestPublicOutput<I>,
Source§type SType = ()
type SType = ()
The input type of serialization, often a reference to
Self::Type.
For “structural” formats though (e.g., crate::regular::sequence::Pair and crate::regular::variant::Choice),
this is the tuple/sum of the corresponding Combinator::SType types.Source§fn length(&self, v: Self::SType) -> usize
fn length(&self, v: Self::SType) -> usize
The length of the output buffer.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
The parsing function.
To enable “zero-copy” parsing, implementations of
parse should not
consume/deepcopy the input buffer I, but rather return a slice of the
input buffer for Self::Type whenever possible.
See crate::buf_traits::VestInput and crate::buf_traits::VestPublicInput for
more details. Read moreSource§fn serialize(
&self,
v: Self::SType,
data: &mut O,
pos: usize,
) -> Result<usize, SerializeError>
fn serialize( &self, v: Self::SType, data: &mut O, pos: usize, ) -> Result<usize, SerializeError>
The serialization function.
The intended use of
serialize is to serialize a value v into the
buffer buf at the position pos “in-place” (i.e., without
allocating a new buffer or extending the buffer). Read moreSource§impl<'x, I, O> Combinator<'x, I, O> for Tag<UnsignedLEB128, UInt>where
I: VestPublicInput,
O: VestPublicOutput<I>,
impl<'x, I, O> Combinator<'x, I, O> for Tag<UnsignedLEB128, UInt>where
I: VestPublicInput,
O: VestPublicOutput<I>,
Source§type SType = ()
type SType = ()
The input type of serialization, often a reference to
Self::Type.
For “structural” formats though (e.g., crate::regular::sequence::Pair and crate::regular::variant::Choice),
this is the tuple/sum of the corresponding Combinator::SType types.Source§fn length(&self, v: Self::SType) -> usize
fn length(&self, v: Self::SType) -> usize
The length of the output buffer.
This can be used to optimize serialization by pre-allocating the buffer.
Source§fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
fn parse(&self, s: I) -> Result<(usize, Self::Type), ParseError>
The parsing function.
To enable “zero-copy” parsing, implementations of
parse should not
consume/deepcopy the input buffer I, but rather return a slice of the
input buffer for Self::Type whenever possible.
See crate::buf_traits::VestInput and crate::buf_traits::VestPublicInput for
more details. Read moreSource§fn serialize(
&self,
v: Self::SType,
data: &mut O,
pos: usize,
) -> Result<usize, SerializeError>
fn serialize( &self, v: Self::SType, data: &mut O, pos: usize, ) -> Result<usize, SerializeError>
The serialization function.
The intended use of
serialize is to serialize a value v into the
buffer buf at the position pos “in-place” (i.e., without
allocating a new buffer or extending the buffer). Read moreSource§impl<Inner: SpecCombinator<Type = T>, T> SpecCombinator for Tag<Inner, T>
impl<Inner: SpecCombinator<Type = T>, T> SpecCombinator for Tag<Inner, T>
impl<Inner, T> DisjointFrom<Tag<Inner, T>> for Tag<Inner, T>where
Inner: SpecCombinator<Type = T>,
impl<Inner: SecureSpecCombinator<Type = T>, T> SecureSpecCombinator for Tag<Inner, 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> UnsafeUnpin for Tag<Inner, T>where
Inner: UnsafeUnpin,
T: UnsafeUnpin,
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> From<T> for T
impl<T> From<T> for T
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.