pub struct Mapped<Inner, M> {
pub inner: Inner,
pub mapper: M,
}Expand description
Mapped { inner, mapper } transforms the inner combinator’s value type.
Lossless mappers preserve all format properties including parser soundness and non-malleability, while lossy mappers may introduce malleability.
Fields§
§inner: InnerThe inner combinator whose values are being transformed.
mapper: MThe mapping between the inner and outer value types.
Trait Implementations§
Source§impl<Inner, M, MRev> Consistency for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> Consistency for Mapped<Inner, BiMap<M, MRev>>
Source§impl<Inner, M> Consistency for Mapped<Inner, M>
impl<Inner, M> Consistency for Mapped<Inner, M>
Source§open spec fn consistent(&self, v: Self::Val) -> bool
open spec fn consistent(&self, v: Self::Val) -> bool
{
&&& self.mapper.wf_out(v)
&&& self.inner.consistent(self.mapper.spec_map_rev(v))
}Source§type Val = <M as SpecMapper>::Out
type Val = <M as SpecMapper>::Out
The type of values whose consistency is being checked.
Source§impl<Inner, M, MRev, T> DerOrd<T> for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev, T> DerOrd<T> for Mapped<Inner, BiMap<M, MRev>>
Source§proof fn lemma_der_serialize_len(&self, value: T::V)
proof fn lemma_der_serialize_len(&self, value: T::V)
Source§open spec fn der_remaining(&self, value: T::V, state: Inner::State) -> Seq<u8>
open spec fn der_remaining(&self, value: T::V, state: Inner::State) -> Seq<u8>
{ self.inner.der_remaining(self.mapper.1.spec_map(value), state) }Source§open spec fn der_state_valid(&self, value: T::V, state: Inner::State) -> bool
open spec fn der_state_valid(&self, value: T::V, state: Inner::State) -> bool
{ self.inner.der_state_valid(self.mapper.1.spec_map(value), state) }Source§impl<Inner, M, MRev> EquivSerializers for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> EquivSerializers for Mapped<Inner, BiMap<M, MRev>>
Source§impl<Inner, M> EquivSerializers for Mapped<Inner, M>
impl<Inner, M> EquivSerializers for Mapped<Inner, M>
Source§impl<Inner, M, MRev> EquivSerializersGeneral for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> EquivSerializersGeneral for Mapped<Inner, BiMap<M, MRev>>
Source§open spec fn equiv_general_inv(&self) -> bool
open spec fn equiv_general_inv(&self) -> bool
{ self.inner.equiv_general_inv() }Source§proof fn lemma_serialize_equiv(&self, v: Self::SVal, obuf: Seq<u8>)
proof fn lemma_serialize_equiv(&self, v: Self::SVal, obuf: Seq<u8>)
Source§impl<Inner, M> EquivSerializersGeneral for Mapped<Inner, M>
impl<Inner, M> EquivSerializersGeneral for Mapped<Inner, M>
Source§open spec fn equiv_general_inv(&self) -> bool
open spec fn equiv_general_inv(&self) -> bool
{ self.inner.equiv_general_inv() }Source§proof fn lemma_serialize_equiv(&self, v: Self::SVal, obuf: Seq<u8>)
proof fn lemma_serialize_equiv(&self, v: Self::SVal, obuf: Seq<u8>)
Source§impl<Inner, M, MRev> GoodSerializer for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> GoodSerializer for Mapped<Inner, BiMap<M, MRev>>
Source§open spec fn serialize_inv(&self) -> bool
open spec fn serialize_inv(&self) -> bool
{ self.inner.serialize_inv() }Source§proof fn lemma_serialize_len(&self, v: M::Output)
proof fn lemma_serialize_len(&self, v: M::Output)
Source§impl<Inner, M> GoodSerializer for Mapped<Inner, M>
impl<Inner, M> GoodSerializer for Mapped<Inner, M>
Source§open spec fn serialize_inv(&self) -> bool
open spec fn serialize_inv(&self) -> bool
{ self.inner.serialize_inv() }Source§proof fn lemma_serialize_len(&self, v: M::Out)
proof fn lemma_serialize_len(&self, v: M::Out)
Source§impl<Inner, Mapper, Reverse> HasAsn1Start for Mapped<Inner, BiMap<Mapper, Reverse>>
BiMap mapping does not change the accepted byte domain.
impl<Inner, Mapper, Reverse> HasAsn1Start for Mapped<Inner, BiMap<Mapper, Reverse>>
BiMap mapping does not change the accepted byte domain.
Source§open spec fn asn1_start(&self) -> Asn1StartDomain
open spec fn asn1_start(&self) -> Asn1StartDomain
{ self.inner.asn1_start() }Source§proof fn lemma_parse_implies_asn1_start(&self, input: Seq<u8>)
proof fn lemma_parse_implies_asn1_start(&self, input: Seq<u8>)
Source§impl<Inner, Mapper> HasAsn1Start for Mapped<Inner, Mapper>
Semantic mapping does not change the accepted byte domain.
impl<Inner, Mapper> HasAsn1Start for Mapped<Inner, Mapper>
Semantic mapping does not change the accepted byte domain.
Source§open spec fn asn1_start(&self) -> Asn1StartDomain
open spec fn asn1_start(&self) -> Asn1StartDomain
{ self.inner.asn1_start() }Source§proof fn lemma_parse_implies_asn1_start(&self, input: Seq<u8>)
proof fn lemma_parse_implies_asn1_start(&self, input: Seq<u8>)
Source§impl<Inner, M, MRev> MinMaxByteLen for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> MinMaxByteLen for Mapped<Inner, BiMap<M, MRev>>
Source§impl<Inner, M> MinMaxByteLen for Mapped<Inner, M>
impl<Inner, M> MinMaxByteLen for Mapped<Inner, M>
Source§impl<Inner, M, MRev> NoLookAhead for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> NoLookAhead for Mapped<Inner, BiMap<M, MRev>>
Source§open spec fn no_lookahead_inv(&self) -> bool
open spec fn no_lookahead_inv(&self) -> bool
{ self.inner.no_lookahead_inv() }Source§proof fn lemma_no_lookahead(&self, i1: Seq<u8>, i2: Seq<u8>)
proof fn lemma_no_lookahead(&self, i1: Seq<u8>, i2: Seq<u8>)
Source§impl<Inner, M> NoLookAhead for Mapped<Inner, M>
impl<Inner, M> NoLookAhead for Mapped<Inner, M>
Source§open spec fn no_lookahead_inv(&self) -> bool
open spec fn no_lookahead_inv(&self) -> bool
{ self.inner.no_lookahead_inv() }Source§proof fn lemma_no_lookahead(&self, i1: Seq<u8>, i2: Seq<u8>)
proof fn lemma_no_lookahead(&self, i1: Seq<u8>, i2: Seq<u8>)
Source§impl<Inner, Out> NonMalleable for Mapped<Inner, FnSpecMapper<Inner::PVal, Out>>where
Inner: SoundParser + NonMalleable,
impl<Inner, Out> NonMalleable for Mapped<Inner, FnSpecMapper<Inner::PVal, Out>>where
Inner: SoundParser + NonMalleable,
Source§open spec fn nonmal_inv(&self) -> bool
open spec fn nonmal_inv(&self) -> bool
{
&&& self.inner.nonmal_inv()
&&& self.inner.sound_inv()
&&& forall |v: Inner::PVal| {
#[trigger] self.inner.consistent(v) ==> (self.mapper.1)((self.mapper.0)(v)) == v
}
}Source§proof fn lemma_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)
proof fn lemma_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)
Source§impl<Inner, M, MRev> NonMalleable for Mapped<Inner, BiMap<M, MRev>>where
Inner: SoundParser + NonMalleable,
M: SpecMap<Input = Inner::PVal>,
MRev: SpecMap<Input = M::Output, Output = M::Input>,
impl<Inner, M, MRev> NonMalleable for Mapped<Inner, BiMap<M, MRev>>where
Inner: SoundParser + NonMalleable,
M: SpecMap<Input = Inner::PVal>,
MRev: SpecMap<Input = M::Output, Output = M::Input>,
Source§open spec fn nonmal_inv(&self) -> bool
open spec fn nonmal_inv(&self) -> bool
{
&&& self.inner.nonmal_inv()
&&& self.inner.sound_inv()
&&& forall |i: Inner::T| self.inner.consistent(i) ==> self.mapper.lossless(i)
}Source§proof fn lemma_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)
proof fn lemma_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)
Source§impl<Inner, M> NonMalleable for Mapped<Inner, M>
impl<Inner, M> NonMalleable for Mapped<Inner, M>
Source§open spec fn nonmal_inv(&self) -> bool
open spec fn nonmal_inv(&self) -> bool
{
&&& self.inner.nonmal_inv()
&&& self.inner.sound_inv()
&&& forall |v: Inner::T| self.inner.consistent(v) ==> self.mapper.wf_in(v)
}Source§proof fn lemma_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)
proof fn lemma_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)
Source§impl<Inner, M, MRev> NonTailFmt for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> NonTailFmt for Mapped<Inner, BiMap<M, MRev>>
Source§open spec fn serialize_dps_inv(&self) -> bool
open spec fn serialize_dps_inv(&self) -> bool
{ self.inner.serialize_dps_inv() }Source§proof fn lemma_serialize_dps_prepend(&self, v: M::Output, obuf: Seq<u8>)
proof fn lemma_serialize_dps_prepend(&self, v: M::Output, obuf: Seq<u8>)
Source§proof fn lemma_serialize_dps_len(&self, v: M::Output, obuf: Seq<u8>)
proof fn lemma_serialize_dps_len(&self, v: M::Output, obuf: Seq<u8>)
Source§impl<Inner, M> NonTailFmt for Mapped<Inner, M>
impl<Inner, M> NonTailFmt for Mapped<Inner, M>
Source§open spec fn serialize_dps_inv(&self) -> bool
open spec fn serialize_dps_inv(&self) -> bool
{ self.inner.serialize_dps_inv() }Source§proof fn lemma_serialize_dps_prepend(&self, v: M::Out, obuf: Seq<u8>)
proof fn lemma_serialize_dps_prepend(&self, v: M::Out, obuf: Seq<u8>)
Source§proof fn lemma_serialize_dps_len(&self, v: M::Out, obuf: Seq<u8>)
proof fn lemma_serialize_dps_len(&self, v: M::Out, obuf: Seq<u8>)
Source§impl<Inner, M, MRev> Productive for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> Productive for Mapped<Inner, BiMap<M, MRev>>
Source§open spec fn productive_inv(&self) -> bool
open spec fn productive_inv(&self) -> bool
{ self.inner.productive_inv() }Source§proof fn lemma_productive(&self, s: Seq<u8>)
proof fn lemma_productive(&self, s: Seq<u8>)
Source§impl<Inner: Productive, Out> Productive for Mapped<Inner, FnSpec<(Inner::PVal,), Out>>
impl<Inner: Productive, Out> Productive for Mapped<Inner, FnSpec<(Inner::PVal,), Out>>
Source§open spec fn productive_inv(&self) -> bool
open spec fn productive_inv(&self) -> bool
{ self.inner.productive_inv() }Source§proof fn lemma_productive(&self, s: Seq<u8>)
proof fn lemma_productive(&self, s: Seq<u8>)
Source§impl<Inner, M> Productive for Mapped<Inner, M>
impl<Inner, M> Productive for Mapped<Inner, M>
Source§open spec fn productive_inv(&self) -> bool
open spec fn productive_inv(&self) -> bool
{ self.inner.productive_inv() }Source§proof fn lemma_productive(&self, s: Seq<u8>)
proof fn lemma_productive(&self, s: Seq<u8>)
Source§impl<F, M> Retaggable for Mapped<F, M>where
F: Retaggable,
M: Copy,
Allows a semantic mapping to remain attached when its underlying ASN.1 format is retagged.
impl<F, M> Retaggable for Mapped<F, M>where
F: Retaggable,
M: Copy,
Allows a semantic mapping to remain attached when its underlying ASN.1 format is retagged.
Retagging is delegated to the inner format and the mapper is preserved.
Source§impl<Inner: SPRoundTripDps, Out> SPRoundTripDps for Mapped<Inner, FnSpecMapper<Inner::T, Out>>
impl<Inner: SPRoundTripDps, Out> SPRoundTripDps for Mapped<Inner, FnSpecMapper<Inner::T, Out>>
Source§open spec fn unambiguous(&self) -> bool
open spec fn unambiguous(&self) -> bool
{
&&& self.inner.unambiguous()
&&& forall |o: Out| {
#[trigger] self.consistent(o) ==> (self.mapper.0)((self.mapper.1)(o)) == o
}
}Source§proof fn theorem_serialize_dps_parse_roundtrip(&self, v: Self::T, obuf: Seq<u8>)
proof fn theorem_serialize_dps_parse_roundtrip(&self, v: Self::T, obuf: Seq<u8>)
Source§impl<Inner, M, MRev> SPRoundTripDps for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> SPRoundTripDps for Mapped<Inner, BiMap<M, MRev>>
Source§open spec fn unambiguous(&self) -> bool
open spec fn unambiguous(&self) -> bool
{
&&& self.inner.unambiguous()
&&& forall |o: M::Output| self.consistent(o) ==> self.mapper.sound(o)
}Source§proof fn theorem_serialize_dps_parse_roundtrip(&self, v: Self::T, obuf: Seq<u8>)
proof fn theorem_serialize_dps_parse_roundtrip(&self, v: Self::T, obuf: Seq<u8>)
Source§impl<Inner, M> SPRoundTripDps for Mapped<Inner, M>
impl<Inner, M> SPRoundTripDps for Mapped<Inner, M>
Source§open spec fn unambiguous(&self) -> bool
open spec fn unambiguous(&self) -> bool
{ self.inner.unambiguous() }Source§proof fn theorem_serialize_dps_parse_roundtrip(&self, v: Self::T, obuf: Seq<u8>)
proof fn theorem_serialize_dps_parse_roundtrip(&self, v: Self::T, obuf: Seq<u8>)
Source§impl<Inner, M, MRev> SafeParser for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> SafeParser for Mapped<Inner, BiMap<M, MRev>>
Source§impl<Inner: SafeParser, Out> SafeParser for Mapped<Inner, FnSpec<(Inner::PVal,), Out>>
impl<Inner: SafeParser, Out> SafeParser for Mapped<Inner, FnSpec<(Inner::PVal,), Out>>
Source§impl<Inner, M> SafeParser for Mapped<Inner, M>
impl<Inner, M> SafeParser for Mapped<Inner, M>
Source§impl<Output: OutputBuf, Inner, M, MRev, T> Serializer<Output, T> for Mapped<Inner, BiMap<M, MRev>>
impl<Output: OutputBuf, Inner, M, MRev, T> Serializer<Output, T> for Mapped<Inner, BiMap<M, MRev>>
Source§exec fn serialize_into(&self, v: &T, obuf: &mut Output)
exec fn serialize_into(&self, v: &T, obuf: &mut Output)
Source§impl<Inner: SoundParser, Out> SoundParser for Mapped<Inner, FnSpecMapper<Inner::PVal, Out>>
impl<Inner: SoundParser, Out> SoundParser for Mapped<Inner, FnSpecMapper<Inner::PVal, Out>>
Source§open spec fn sound_inv(&self) -> bool
open spec fn sound_inv(&self) -> bool
{
&&& self.inner.sound_inv()
&&& forall |v: Inner::T| {
#[trigger] self.inner.consistent(v) ==> (self.mapper.1)((self.mapper.0)(v)) == v
}
}Source§proof fn lemma_parse_sound_consumption(&self, ibuf: Seq<u8>)
proof fn lemma_parse_sound_consumption(&self, ibuf: Seq<u8>)
Source§proof fn lemma_parse_sound_value(&self, ibuf: Seq<u8>)
proof fn lemma_parse_sound_value(&self, ibuf: Seq<u8>)
Source§impl<Inner, M, MRev> SoundParser for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> SoundParser for Mapped<Inner, BiMap<M, MRev>>
Source§impl<Inner, M> SoundParser for Mapped<Inner, M>
impl<Inner, M> SoundParser for Mapped<Inner, M>
Source§impl<Inner, M, MRev> SpecByteLen for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> SpecByteLen for Mapped<Inner, BiMap<M, MRev>>
Source§impl<Inner, M> SpecByteLen for Mapped<Inner, M>
impl<Inner, M> SpecByteLen for Mapped<Inner, M>
Source§impl<Inner, M, MRev> SpecParser for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> SpecParser for Mapped<Inner, BiMap<M, MRev>>
Source§impl<Inner: SpecParser, Out> SpecParser for Mapped<Inner, FnSpec<(Inner::PVal,), Out>>
impl<Inner: SpecParser, Out> SpecParser for Mapped<Inner, FnSpec<(Inner::PVal,), Out>>
Source§impl<Inner, M> SpecParser for Mapped<Inner, M>
impl<Inner, M> SpecParser for Mapped<Inner, M>
Source§impl<Inner, M, MRev> SpecSerializer for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> SpecSerializer for Mapped<Inner, BiMap<M, MRev>>
Source§impl<Inner: SpecSerializer, Out> SpecSerializer for Mapped<Inner, FnSpec<(Out,), Inner::SVal>>
impl<Inner: SpecSerializer, Out> SpecSerializer for Mapped<Inner, FnSpec<(Out,), Inner::SVal>>
Source§impl<Inner, M> SpecSerializer for Mapped<Inner, M>
impl<Inner, M> SpecSerializer for Mapped<Inner, M>
Source§open spec fn spec_serialize(&self, v: M::Out) -> Seq<u8>
open spec fn spec_serialize(&self, v: M::Out) -> Seq<u8>
{ self.inner.spec_serialize(self.mapper.spec_map_rev(v)) }Source§type SVal = <M as SpecMapper>::Out
type SVal = <M as SpecMapper>::Out
The type of values to be serialized.
Source§impl<Inner, M, MRev> SpecSerializerDps for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> SpecSerializerDps for Mapped<Inner, BiMap<M, MRev>>
Source§impl<Inner: SpecSerializerDps, Out> SpecSerializerDps for Mapped<Inner, FnSpec<(Out,), Inner::SValue>>
impl<Inner: SpecSerializerDps, Out> SpecSerializerDps for Mapped<Inner, FnSpec<(Out,), Inner::SValue>>
Source§impl<Inner, M> SpecSerializerDps for Mapped<Inner, M>
impl<Inner, M> SpecSerializerDps for Mapped<Inner, M>
Source§impl<Inner, M, MRev> StaticByteLen for Mapped<Inner, BiMap<M, MRev>>
impl<Inner, M, MRev> StaticByteLen for Mapped<Inner, BiMap<M, MRev>>
Source§open spec fn static_byte_len() -> nat
open spec fn static_byte_len() -> nat
{ Inner::static_byte_len() }Source§proof fn lemma_static_len_matches_byte_len(&self, v: Self::T)
proof fn lemma_static_len_matches_byte_len(&self, v: Self::T)
Source§impl<Inner, M> StaticByteLen for Mapped<Inner, M>
impl<Inner, M> StaticByteLen for Mapped<Inner, M>
Source§open spec fn static_byte_len() -> nat
open spec fn static_byte_len() -> nat
{ Inner::static_byte_len() }Source§proof fn lemma_static_len_matches_byte_len(&self, v: Self::T)
proof fn lemma_static_len_matches_byte_len(&self, v: Self::T)
impl<Inner: Copy, M: Copy> Copy for Mapped<Inner, M>
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> UnsafeUnpin for Mapped<Inner, M>where
Inner: UnsafeUnpin,
M: UnsafeUnpin,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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<C> NonAmbiguous for Cwhere
C: SPRoundTrip,
impl<C> NonAmbiguous for Cwhere
C: SPRoundTrip,
Source§open spec fn nonamb_inv(&self) -> bool
open spec fn nonamb_inv(&self) -> bool
{ self.sp_roundtrip_inv() }Source§proof fn lemma_serialize_injective(
&self,
v1: <C as Consistency>::Val,
v2: <C as Consistency>::Val,
)
proof fn lemma_serialize_injective( &self, v1: <C as Consistency>::Val, v2: <C as Consistency>::Val, )
Source§impl<C> PSRoundTrip for C
impl<C> PSRoundTrip for C
Source§open spec fn ps_roundtrip_inv(&self) -> bool
open spec fn ps_roundtrip_inv(&self) -> bool
{ self.safe_inv() && self.sound_inv() && self.nonmal_inv() && self.sp_roundtrip_inv() }Source§proof fn theorem_parse_serialize_roundtrip(&self, ibuf: Seq<u8>)
proof fn theorem_parse_serialize_roundtrip(&self, ibuf: Seq<u8>)
Source§impl<C> SPRoundTrip for C
impl<C> SPRoundTrip for C
Source§open spec fn sp_roundtrip_inv(&self) -> bool
open spec fn sp_roundtrip_inv(&self) -> bool
{ self.serialize_inv() && self.equiv_inv() && self.unambiguous() }