pub struct Mapped<Inner, M> {
pub inner: Inner,
pub mapper: M,
}
Expand description
Combinator that maps the result of an inner
combinator with an isomorphism that implements
Iso
.
Fields§
§inner: Inner
The inner combinator.
mapper: M
The isomorphism.
Trait Implementations§
Source§impl<Inner, M> Combinator for Mapped<Inner, M>where
M: for<'a> Iso<Src<'a> = <Inner as Combinator>::Result<'a>, SrcOwned = <Inner as Combinator>::Owned>,
Inner: Combinator,
<Inner as Combinator>::Result<'a>: for<'a> From<<M as Iso>::Dst<'a>> + for<'a> View,
<M as Iso>::Dst<'a>: for<'a> From<<Inner as Combinator>::Result<'a>> + for<'a> View,
<M as View>::V: SpecIso<Src = <<Inner as Combinator>::Owned as View>::V, Dst = <<M as Iso>::DstOwned as View>::V>,
<Inner as View>::V: SecureSpecCombinator<SpecResult = <<Inner as Combinator>::Owned as View>::V>,
<<Inner as Combinator>::Owned as View>::V: SpecFrom<<<M as Iso>::DstOwned as View>::V>,
<<M as Iso>::DstOwned as View>::V: SpecFrom<<<Inner as Combinator>::Owned as View>::V>,
impl<Inner, M> Combinator for Mapped<Inner, M>where
M: for<'a> Iso<Src<'a> = <Inner as Combinator>::Result<'a>, SrcOwned = <Inner as Combinator>::Owned>,
Inner: Combinator,
<Inner as Combinator>::Result<'a>: for<'a> From<<M as Iso>::Dst<'a>> + for<'a> View,
<M as Iso>::Dst<'a>: for<'a> From<<Inner as Combinator>::Result<'a>> + for<'a> View,
<M as View>::V: SpecIso<Src = <<Inner as Combinator>::Owned as View>::V, Dst = <<M as Iso>::DstOwned as View>::V>,
<Inner as View>::V: SecureSpecCombinator<SpecResult = <<Inner as Combinator>::Owned as View>::V>,
<<Inner as Combinator>::Owned as View>::V: SpecFrom<<<M as Iso>::DstOwned as View>::V>,
<<M as Iso>::DstOwned as View>::V: SpecFrom<<<Inner as Combinator>::Owned as View>::V>,
Source§type Result<'a> = <M as Iso>::Dst<'a>
type Result<'a> = <M as Iso>::Dst<'a>
The result type of parsing and the input type of serialization.
Source§type Owned = <M as Iso>::DstOwned
type Owned = <M as Iso>::DstOwned
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, <Mapped<Inner, M> as Combinator>::Result<'a>), ParseError>
fn parse<'a>( &self, s: &'a [u8], ) -> Result<(usize, <Mapped<Inner, M> as Combinator>::Result<'a>), ParseError>
The parsing function.
Source§impl<Inner, M> SpecCombinator for Mapped<Inner, M>where
Inner: SpecCombinator,
M: SpecIso<Src = <Inner as SpecCombinator>::SpecResult>,
<Inner as SpecCombinator>::SpecResult: SpecFrom<<M as SpecIso>::Dst>,
<M as SpecIso>::Dst: SpecFrom<<Inner as SpecCombinator>::SpecResult>,
impl<Inner, M> SpecCombinator for Mapped<Inner, M>where
Inner: SpecCombinator,
M: SpecIso<Src = <Inner as SpecCombinator>::SpecResult>,
<Inner as SpecCombinator>::SpecResult: SpecFrom<<M as SpecIso>::Dst>,
<M as SpecIso>::Dst: SpecFrom<<Inner as SpecCombinator>::SpecResult>,
Source§type SpecResult = <M as SpecIso>::Dst
type SpecResult = <M as SpecIso>::Dst
The view of
Combinator::Result
.impl<U1, U2, M1, M2> DisjointFrom<Mapped<U2, M2>> for Mapped<U1, M1>where
U1: DisjointFrom<U2>,
U2: SpecCombinator,
M1: SpecIso<Src = <U1 as SpecCombinator>::SpecResult>,
M2: SpecIso<Src = <U2 as SpecCombinator>::SpecResult>,
<U1 as SpecCombinator>::SpecResult: SpecFrom<<M1 as SpecIso>::Dst>,
<U2 as SpecCombinator>::SpecResult: SpecFrom<<M2 as SpecIso>::Dst>,
<M1 as SpecIso>::Dst: SpecFrom<<U1 as SpecCombinator>::SpecResult>,
<M2 as SpecIso>::Dst: SpecFrom<<U2 as SpecCombinator>::SpecResult>,
impl<Inner, M> SecureSpecCombinator for Mapped<Inner, M>where
Inner: SecureSpecCombinator,
M: SpecIso<Src = <Inner as SpecCombinator>::SpecResult>,
<Inner as SpecCombinator>::SpecResult: SpecFrom<<M as SpecIso>::Dst>,
<M as SpecIso>::Dst: SpecFrom<<Inner as SpecCombinator>::SpecResult>,
Auto Trait Implementations§
impl<Inner, M> Freeze for Mapped<Inner, M>
impl<Inner, M> RefUnwindSafe for Mapped<Inner, M>where
Inner: RefUnwindSafe,
M: RefUnwindSafe,
impl<Inner, M> Send for Mapped<Inner, M>
impl<Inner, M> Sync for Mapped<Inner, M>
impl<Inner, M> Unpin for Mapped<Inner, M>
impl<Inner, M> UnwindSafe for Mapped<Inner, M>where
Inner: UnwindSafe,
M: 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 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.