pub struct TryMap<Inner, M> {
pub inner: Inner,
pub mapper: M,
}Expand description
Combinator that maps the result of an inner combinator with a fallible conversion
that implements [TryFromInto].
Fields§
§inner: InnerThe inner combinator.
mapper: MThe fallible conversion.
Trait Implementations§
Source§impl<'x, I, O, Inner, M> Combinator<'x, I, O> for TryMap<Inner, M>where
I: VestInput,
O: VestOutput<I>,
Inner: Combinator<'x, I, O>,
Inner::V: SecureSpecCombinator<Type = <Inner::Type as View>::V>,
M: PartialIso<'x, Src = Inner::Type, RefSrc = Inner::SType>,
M::Dst: TryFrom<Inner::Type> + View,
Inner::SType: TryFrom<&'x M::Dst> + View,
M::V: SpecPartialIsoProof<Src = <Inner::Type as View>::V, Dst = <M::Dst as View>::V>,
<Inner::Type as View>::V: SpecTryFrom<<M::Dst as View>::V>,
<M::Dst as View>::V: SpecTryFrom<<Inner::Type as View>::V>,
<Inner::SType as TryFrom<&'x M::Dst>>::Error: Debug,
impl<'x, I, O, Inner, M> Combinator<'x, I, O> for TryMap<Inner, M>where
I: VestInput,
O: VestOutput<I>,
Inner: Combinator<'x, I, O>,
Inner::V: SecureSpecCombinator<Type = <Inner::Type as View>::V>,
M: PartialIso<'x, Src = Inner::Type, RefSrc = Inner::SType>,
M::Dst: TryFrom<Inner::Type> + View,
Inner::SType: TryFrom<&'x M::Dst> + View,
M::V: SpecPartialIsoProof<Src = <Inner::Type as View>::V, Dst = <M::Dst as View>::V>,
<Inner::Type as View>::V: SpecTryFrom<<M::Dst as View>::V>,
<M::Dst as View>::V: SpecTryFrom<<Inner::Type as View>::V>,
<Inner::SType as TryFrom<&'x M::Dst>>::Error: Debug,
Source§open spec fn ex_requires(&self) -> bool
open spec fn ex_requires(&self) -> bool
{ self.inner.ex_requires() }Source§exec fn serialize(
&self,
v: Self::SType,
data: &mut O,
pos: usize,
) -> res : Result<usize, SerializeError>
exec fn serialize( &self, v: Self::SType, data: &mut O, pos: usize, ) -> res : Result<usize, SerializeError>
Source§type Type = <M as PartialIso<'x>>::Dst
type Type = <M as PartialIso<'x>>::Dst
The result type of parsing
Source§type SType = &'x <M as PartialIso<'x>>::Dst
type SType = &'x <M as PartialIso<'x>>::Dst
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§impl<U, M1, M2> DisjointFrom<TryMap<U, M2>> for TryMap<U, M1>where
U: SpecCombinator,
M1: SpecPartialIsoFn<Src = U::Type>,
M2: SpecPartialIsoFn<Src = U::Type>,
U::Type: SpecTryFrom<M1::Dst> + SpecTryFrom<M2::Dst>,
M1::Dst: SpecTryFrom<U::Type>,
M2::Dst: SpecTryFrom<U::Type>,
impl<U, M1, M2> DisjointFrom<TryMap<U, M2>> for TryMap<U, M1>where
U: SpecCombinator,
M1: SpecPartialIsoFn<Src = U::Type>,
M2: SpecPartialIsoFn<Src = U::Type>,
U::Type: SpecTryFrom<M1::Dst> + SpecTryFrom<M2::Dst>,
M1::Dst: SpecTryFrom<U::Type>,
M2::Dst: SpecTryFrom<U::Type>,
Source§open spec fn disjoint_from(&self, other: &TryMap<U, M2>) -> bool
open spec fn disjoint_from(&self, other: &TryMap<U, M2>) -> bool
{
self.inner == other.inner
&& forall |t| {
<M1 as SpecPartialIsoFn>::spec_apply(t) is Ok
==> <M2 as SpecPartialIsoFn>::spec_apply(t) is Err
}
}Source§proof fn parse_disjoint_on(&self, other: &TryMap<U, M2>, buf: Seq<u8>)
proof fn parse_disjoint_on(&self, other: &TryMap<U, M2>, buf: Seq<u8>)
Source§impl<Inner, M> SecureSpecCombinator for TryMap<Inner, M>where
Inner: SecureSpecCombinator,
M: SpecPartialIsoProof<Src = Inner::Type>,
Inner::Type: SpecTryFrom<M::Dst>,
M::Dst: SpecTryFrom<Inner::Type>,
impl<Inner, M> SecureSpecCombinator for TryMap<Inner, M>where
Inner: SecureSpecCombinator,
M: SpecPartialIsoProof<Src = Inner::Type>,
Inner::Type: SpecTryFrom<M::Dst>,
M::Dst: SpecTryFrom<Inner::Type>,
Source§open spec fn is_prefix_secure() -> bool
open spec fn is_prefix_secure() -> bool
{ Inner::is_prefix_secure() }Source§open spec fn is_productive(&self) -> bool
open spec fn is_productive(&self) -> bool
{ self.inner.is_productive() }Source§proof fn theorem_serialize_parse_roundtrip(&self, v: Self::Type)
proof fn theorem_serialize_parse_roundtrip(&self, v: Self::Type)
Source§proof fn theorem_parse_serialize_roundtrip(&self, buf: Seq<u8>)
proof fn theorem_parse_serialize_roundtrip(&self, buf: Seq<u8>)
Source§proof fn lemma_prefix_secure(&self, s1: Seq<u8>, s2: Seq<u8>)
proof fn lemma_prefix_secure(&self, s1: Seq<u8>, s2: Seq<u8>)
Source§proof fn lemma_parse_length(&self, s: Seq<u8>)
proof fn lemma_parse_length(&self, s: Seq<u8>)
Source§proof fn lemma_parse_productive(&self, s: Seq<u8>)
proof fn lemma_parse_productive(&self, s: Seq<u8>)
Source§fn corollary_parse_surjective(&self, v: Self::Type)
fn corollary_parse_surjective(&self, v: Self::Type)
Source§fn corollary_serialize_injective_contraposition(
&self,
v1: Self::Type,
v2: Self::Type,
)
fn corollary_serialize_injective_contraposition( &self, v1: Self::Type, v2: Self::Type, )
Source§fn lemma_serialize_productive(&self, v: Self::Type)
fn lemma_serialize_productive(&self, v: Self::Type)
Source§impl<Inner, M> SpecCombinator for TryMap<Inner, M>where
Inner: SpecCombinator,
M: SpecPartialIso<Src = Inner::Type>,
Inner::Type: SpecTryFrom<M::Dst>,
M::Dst: SpecTryFrom<Inner::Type>,
impl<Inner, M> SpecCombinator for TryMap<Inner, M>where
Inner: SpecCombinator,
M: SpecPartialIso<Src = Inner::Type>,
Inner::Type: SpecTryFrom<M::Dst>,
M::Dst: SpecTryFrom<Inner::Type>,
Source§open spec fn wf(&self, v: Self::Type) -> bool
open spec fn wf(&self, v: Self::Type) -> bool
{
match M::spec_rev_apply(v) {
Ok(v) => self.inner.wf(v),
Err(_) => false,
}
}Source§open spec fn spec_parse(&self, s: Seq<u8>) -> Option<(int, Self::Type)>
open spec fn spec_parse(&self, s: Seq<u8>) -> Option<(int, Self::Type)>
{
match self.inner.spec_parse(s) {
Some((n, v)) => {
match M::spec_apply(v) {
Ok(v) => Some((n, v)),
Err(_) => None,
}
}
None => None,
}
}Source§open spec fn spec_serialize(&self, v: Self::Type) -> Seq<u8>
open spec fn spec_serialize(&self, v: Self::Type) -> Seq<u8>
{
match M::spec_rev_apply(v) {
Ok(v) => self.inner.spec_serialize(v),
Err(_) => Seq::empty(),
}
}Source§type Type = <M as SpecPartialIso>::Dst
type Type = <M as SpecPartialIso>::Dst
The view of [
Combinator::Result].Auto Trait Implementations§
impl<Inner, M> Freeze for TryMap<Inner, M>
impl<Inner, M> RefUnwindSafe for TryMap<Inner, M>where
Inner: RefUnwindSafe,
M: RefUnwindSafe,
impl<Inner, M> Send for TryMap<Inner, M>
impl<Inner, M> Sync for TryMap<Inner, M>
impl<Inner, M> Unpin for TryMap<Inner, M>
impl<Inner, M> UnwindSafe for TryMap<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
§impl<T, VERUS_SPEC__A> FromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: From<T>,
impl<T, VERUS_SPEC__A> FromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: From<T>,
fn obeys_from_spec() -> bool
fn from_spec(v: T) -> VERUS_SPEC__A
§impl<T, VERUS_SPEC__A> IntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: Into<T>,
impl<T, VERUS_SPEC__A> IntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: Into<T>,
fn obeys_into_spec() -> bool
fn into_spec(self) -> T
§impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
fn obeys_into_spec() -> bool
fn into_spec(self) -> U
Source§impl<T, U> SpecTryInto<U> for Twhere
U: SpecTryFrom<T>,
impl<T, U> SpecTryInto<U> for Twhere
U: SpecTryFrom<T>,
Source§open spec fn spec_try_into(self) -> Result<U, <U as SpecTryFrom<T>>::Error>
open spec fn spec_try_into(self) -> Result<U, <U as SpecTryFrom<T>>::Error>
{ U::spec_try_from(self) }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.