Skip to main content

Tag

Struct Tag 

Source
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§

Source§

impl<Inner, T> Tag<Inner, T>

Source

pub fn new(inner: Inner, tag: T) -> Self

Creates a new Tag combinator.

Trait Implementations§

Source§

impl<'x, const N: usize> Combinator<'x, &'x [u8], Vec<u8>> for Tag<Fixed<N>, [u8; N]>

Source§

type Type = ()

The result type of parsing
Source§

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

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>

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 more
Source§

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 more
Source§

impl<'x, I, O> Combinator<'x, I, O> for Tag<U16Be, u16>

Source§

type Type = ()

The result type of parsing
Source§

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

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>

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 more
Source§

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 more
Source§

impl<'x, I, O> Combinator<'x, I, O> for Tag<U16Le, u16>

Source§

type Type = ()

The result type of parsing
Source§

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

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>

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 more
Source§

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 more
Source§

impl<'x, I, O> Combinator<'x, I, O> for Tag<U32Be, u32>

Source§

type Type = ()

The result type of parsing
Source§

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

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>

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 more
Source§

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 more
Source§

impl<'x, I, O> Combinator<'x, I, O> for Tag<U32Le, u32>

Source§

type Type = ()

The result type of parsing
Source§

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

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>

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 more
Source§

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 more
Source§

impl<'x, I, O> Combinator<'x, I, O> for Tag<U64Be, u64>

Source§

type Type = ()

The result type of parsing
Source§

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

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>

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 more
Source§

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 more
Source§

impl<'x, I, O> Combinator<'x, I, O> for Tag<U64Le, u64>

Source§

type Type = ()

The result type of parsing
Source§

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

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>

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 more
Source§

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 more
Source§

impl<'x, I, O> Combinator<'x, I, O> for Tag<U8, u8>

Source§

type Type = ()

The result type of parsing
Source§

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

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>

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 more
Source§

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 more
Source§

impl<'x, I, O> Combinator<'x, I, O> for Tag<UnsignedLEB128, UInt>

Source§

type Type = ()

The result type of parsing
Source§

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

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>

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 more
Source§

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 more
Source§

impl<Inner: SpecCombinator<Type = T>, T> SpecCombinator for Tag<Inner, T>

Source§

type Type = ()

The view of [Combinator::Result].
Source§

impl<Inner: View, T: View> View for Tag<Inner, T>

Source§

type V = Tag<<Inner as View>::V, <T as View>::V>

Source§

impl<Inner, T> DisjointFrom<Tag<Inner, T>> for Tag<Inner, T>
where Inner: SpecCombinator<Type = T>,

Source§

impl<Inner: SecureSpecCombinator<Type = T>, T> SecureSpecCombinator for Tag<Inner, T>

Auto Trait Implementations§

§

impl<Inner, T> Freeze for Tag<Inner, T>
where Inner: Freeze, T: Freeze,

§

impl<Inner, T> RefUnwindSafe for Tag<Inner, T>
where Inner: RefUnwindSafe, T: RefUnwindSafe,

§

impl<Inner, T> Send for Tag<Inner, T>
where Inner: Send, T: Send,

§

impl<Inner, T> Sync for Tag<Inner, T>
where Inner: Sync, T: Sync,

§

impl<Inner, T> Unpin for Tag<Inner, T>
where Inner: Unpin, T: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T
where T: View, <T as View>::V: SpecFrom<<T as View>::V>,

Source§

fn ex_from(t: T) -> T

Vest equivalent of std::convert::From::from.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where T: View, U: View + From<T>, <U as View>::V: SpecFrom<<T as View>::V>,

Source§

fn ex_into(self) -> U

Vest equivalent of std::convert::Into::into.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> SpecTryInto<U> for T
where U: SpecTryFrom<T>,

Source§

type Error = <U as SpecTryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where T: View, U: View + TryFrom<T>, <U as View>::V: SpecTryFrom<<T as View>::V>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn ex_try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> SpecFrom<T> for T

Source§

impl<T, U> SpecInto<U> for T
where U: SpecFrom<T>,