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

Source§

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

Source

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

Creates a new Tag combinator.

Trait Implementations§

Source§

impl<'a> Clone for Tag<Bytes, &'a [u8]>

Source§

fn clone(&self) -> Tag<Bytes, &'a [u8]>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, const N: usize> Clone for Tag<BytesN<N>, &'a [u8]>

Source§

fn clone(&self) -> Tag<BytesN<N>, &'a [u8]>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Clone for Tag<U16, u16>

Source§

fn clone(&self) -> Tag<U16, u16>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Clone for Tag<U32, u32>

Source§

fn clone(&self) -> Tag<U32, u32>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Clone for Tag<U64, u64>

Source§

fn clone(&self) -> Tag<U64, u64>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Clone for Tag<U8, u8>

Source§

fn clone(&self) -> Tag<U8, u8>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
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>>,

Source§

type Result<'b> = ()

The result type of parsing and the input type of serialization.
Source§

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>

The length of the output buffer, if known. This can be used to optimize serialization by pre-allocating the buffer.
Source§

fn parse<'b>( &self, s: &'b [u8], ) -> Result<(usize, <Tag<Inner, &'a [u8]> as Combinator>::Result<'b>), ParseError>

The parsing function.
Source§

fn serialize( &self, _v: <Tag<Inner, &'a [u8]> as Combinator>::Result<'_>, data: &mut Vec<u8>, pos: usize, ) -> Result<usize, SerializeError>

The serialization function.
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>>,

Source§

type Result<'b> = ()

The result type of parsing and the input type of serialization.
Source§

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>

The length of the output buffer, if known. This can be used to optimize serialization by pre-allocating the buffer.
Source§

fn parse<'b>( &self, s: &'b [u8], ) -> Result<(usize, <Tag<Inner, [u8; N]> as Combinator>::Result<'b>), ParseError>

The parsing function.
Source§

fn serialize( &self, _v: <Tag<Inner, [u8; N]> as Combinator>::Result<'_>, data: &mut Vec<u8>, pos: usize, ) -> Result<usize, SerializeError>

The serialization function.
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,

Source§

type Result<'a> = ()

The result type of parsing and the input type of serialization.
Source§

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>

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>

The parsing function.
Source§

fn serialize( &self, _v: <Tag<Inner, T> as Combinator>::Result<'_>, data: &mut Vec<u8>, pos: usize, ) -> Result<usize, SerializeError>

The serialization function.
Source§

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

Source§

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

Source§

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

Source§

impl DisjointFrom<Tag<Bytes, Seq<u8>>> for Tag<Bytes, Seq<u8>>

Source§

impl<const N: usize> DisjointFrom<Tag<BytesN<N>, Seq<u8>>> for Tag<BytesN<N>, Seq<u8>>

Source§

impl DisjointFrom<Tag<U16, u16>> for Tag<U16, u16>

Source§

impl DisjointFrom<Tag<U32, u32>> for Tag<U32, u32>

Source§

impl DisjointFrom<Tag<U64, u64>> for Tag<U64, u64>

Source§

impl DisjointFrom<Tag<U8, u8>> for Tag<U8, u8>

Source§

impl<Inner, T> SecureSpecCombinator for Tag<Inner, T>
where Inner: SecureSpecCombinator<SpecResult = 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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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> 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> 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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 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, 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> SpecFrom<T> for T

Source§

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