pub struct Implicit<Head, Tail>(pub Head, pub Tail);Expand description
Dependent sequential combinator with deterministic key recovery.
Parsing semantics: parse Head to get a key, then parse the
body via Tail::apply(key). Only the body value is returned.
The key is recovered via Tail::recover(value) during serialization.
§Consistency
A value v: Tail::Val is consistent with Implicit(Head, Tail) iff
let key = self.1.recover(v);
self.0.consistent(key) && self.1.apply(key).consistent(v)§Unambiguity
self.0.unambiguous() &&
forall|key: Head::PVal| #[trigger] (self.1.apply(key)).unambiguous()Tuple Fields§
§0: Head§1: TailTrait Implementations§
Source§impl<Head, Tail> Consistency for Implicit<Head, Tail>
impl<Head, Tail> Consistency for Implicit<Head, Tail>
Source§open spec fn consistent(&self, value: Self::Val) -> bool
open spec fn consistent(&self, value: Self::Val) -> bool
{
let key = self.1.recover(value);
self.0.consistent(key) && self.1.apply(key).consistent(value)
}Source§type Val = <Tail as DepCombinator>::Val
type Val = <Tail as DepCombinator>::Val
The type of values whose consistency is being checked.
Source§impl<Head, Nested> DepCombinator for Implicit<Head, Nested>
impl<Head, Nested> DepCombinator for Implicit<Head, Nested>
Source§open spec fn recover_inv(&self) -> bool
open spec fn recover_inv(&self) -> bool
{ self.1.recover_inv() }Source§proof fn lemma_recover_consistent(&self, key: Self::Key, value: Self::Val)
proof fn lemma_recover_consistent(&self, key: Self::Key, value: Self::Val)
Source§type Key = <Head as Consistency>::Val
type Key = <Head as Consistency>::Val
The type of keys parsed by the head combinator/to be recovered during serialization.
Source§type Val = <Nested as DepCombinator>::Val
type Val = <Nested as DepCombinator>::Val
The type of values consumed/produced by the body combinator.
Source§type Body = <Nested as DepCombinator>::Body
type Body = <Nested as DepCombinator>::Body
The type of the body combinator produced by
apply.Source§impl<Head, Tail> EquivSerializers for Implicit<Head, Tail>where
Head: EquivSerializersGeneral,
Tail: DepCombinator<Key = Head::SVal>,
Tail::Body: EquivSerializers<SVal = Tail::Val>,
impl<Head, Tail> EquivSerializers for Implicit<Head, Tail>where
Head: EquivSerializersGeneral,
Tail: DepCombinator<Key = Head::SVal>,
Tail::Body: EquivSerializers<SVal = Tail::Val>,
Source§impl<Head, Tail> EquivSerializersGeneral for Implicit<Head, Tail>where
Head: EquivSerializersGeneral,
Tail: DepCombinator<Key = Head::SVal>,
Tail::Body: EquivSerializersGeneral<SVal = Tail::Val>,
impl<Head, Tail> EquivSerializersGeneral for Implicit<Head, Tail>where
Head: EquivSerializersGeneral,
Tail: DepCombinator<Key = Head::SVal>,
Tail::Body: EquivSerializersGeneral<SVal = Tail::Val>,
Source§open spec fn equiv_general_inv(&self) -> bool
open spec fn equiv_general_inv(&self) -> bool
{
&&& self.0.equiv_general_inv()
&&& forall |key: Head::SVal| #[trigger] self.1.apply(key).equiv_general_inv()
}Source§proof fn lemma_serialize_equiv(&self, value: Self::SVal, obuf: Seq<u8>)
proof fn lemma_serialize_equiv(&self, value: Self::SVal, obuf: Seq<u8>)
Source§impl<Head, Tail> GoodSerializer for Implicit<Head, Tail>where
Head: GoodSerializer,
Tail: DepCombinator<Key = Head::SVal>,
Tail::Body: GoodSerializer<T = Tail::Val>,
impl<Head, Tail> GoodSerializer for Implicit<Head, Tail>where
Head: GoodSerializer,
Tail: DepCombinator<Key = Head::SVal>,
Tail::Body: GoodSerializer<T = Tail::Val>,
Source§open spec fn serialize_inv(&self) -> bool
open spec fn serialize_inv(&self) -> bool
{
&&& self.0.serialize_inv()
&&& forall |key: Head::SVal| #[trigger] self.1.apply(key).serialize_inv()
}Source§proof fn lemma_serialize_len(&self, value: Self::SVal)
proof fn lemma_serialize_len(&self, value: Self::SVal)
Source§impl<Head, Tail> NoLookAhead for Implicit<Head, Tail>where
Head: NoLookAhead,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: NoLookAhead<PVal = Tail::Val>,
impl<Head, Tail> NoLookAhead for Implicit<Head, Tail>where
Head: NoLookAhead,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: NoLookAhead<PVal = Tail::Val>,
Source§open spec fn no_lookahead_inv(&self) -> bool
open spec fn no_lookahead_inv(&self) -> bool
{
&&& self.0.no_lookahead_inv()
&&& forall |key: Head::PVal| #[trigger] self.1.apply(key).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<Head, Tail> NonMalleable for Implicit<Head, Tail>where
Head: SoundParser + NonMalleable,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: SoundParser<T = Tail::Val> + NonMalleable,
impl<Head, Tail> NonMalleable for Implicit<Head, Tail>where
Head: SoundParser + NonMalleable,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: SoundParser<T = Tail::Val> + NonMalleable,
Source§open spec fn nonmal_inv(&self) -> bool
open spec fn nonmal_inv(&self) -> bool
{
&&& self.0.nonmal_inv()
&&& self.0.sound_inv()
&&& forall |key: Head::PVal| #[trigger] self.1.apply(key).nonmal_inv()
&&& forall |key: Head::PVal| #[trigger] self.1.apply(key).sound_inv()
&&& self.1.recover_inv()
}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<Head, Tail> NonTailFmt for Implicit<Head, Tail>where
Head: NonTailFmt,
Tail: DepCombinator<Key = Head::SValue>,
Tail::Body: NonTailFmt<T = Tail::Val>,
impl<Head, Tail> NonTailFmt for Implicit<Head, Tail>where
Head: NonTailFmt,
Tail: DepCombinator<Key = Head::SValue>,
Tail::Body: NonTailFmt<T = Tail::Val>,
Source§open spec fn serialize_dps_inv(&self) -> bool
open spec fn serialize_dps_inv(&self) -> bool
{
&&& self.0.serialize_dps_inv()
&&& forall |key: Head::SValue| #[trigger] self.1.apply(key).serialize_dps_inv()
}Source§proof fn lemma_serialize_dps_prepend(&self, value: Self::SValue, obuf: Seq<u8>)
proof fn lemma_serialize_dps_prepend(&self, value: Self::SValue, obuf: Seq<u8>)
Source§proof fn lemma_serialize_dps_len(&self, value: Self::SValue, obuf: Seq<u8>)
proof fn lemma_serialize_dps_len(&self, value: Self::SValue, obuf: Seq<u8>)
Source§impl<Head, Tail> Productive for Implicit<Head, Tail>where
Head: Productive,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: Productive<PVal = Tail::Val>,
impl<Head, Tail> Productive for Implicit<Head, Tail>where
Head: Productive,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: Productive<PVal = Tail::Val>,
Source§open spec fn productive_inv(&self) -> bool
open spec fn productive_inv(&self) -> bool
{
||| self.0.productive_inv()
||| forall |key: Head::PVal| #[trigger] self.1.apply(key).productive_inv()
}Source§proof fn lemma_productive(&self, s: Seq<u8>)
proof fn lemma_productive(&self, s: Seq<u8>)
Source§impl<Head, Tail> SPRoundTripDps for Implicit<Head, Tail>where
Head: SPRoundTripDps + NonTailFmt,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: SPRoundTripDps<T = Tail::Val>,
impl<Head, Tail> SPRoundTripDps for Implicit<Head, Tail>where
Head: SPRoundTripDps + NonTailFmt,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: SPRoundTripDps<T = Tail::Val>,
Source§open spec fn unambiguous(&self) -> bool
open spec fn unambiguous(&self) -> bool
{
&&& self.0.serialize_dps_inv()
&&& self.0.unambiguous()
&&& forall |key: Head::T| #[trigger] self.1.apply(key).unambiguous()
}Source§proof fn theorem_serialize_dps_parse_roundtrip(&self, value: Self::T, obuf: Seq<u8>)
proof fn theorem_serialize_dps_parse_roundtrip(&self, value: Self::T, obuf: Seq<u8>)
Source§impl<Head, Tail> SafeParser for Implicit<Head, Tail>where
Head: SafeParser,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: SafeParser<PVal = Tail::Val>,
impl<Head, Tail> SafeParser for Implicit<Head, Tail>where
Head: SafeParser,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: SafeParser<PVal = Tail::Val>,
Source§impl<Head, Tail> SoundParser for Implicit<Head, Tail>where
Head: SoundParser,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: SoundParser<T = Tail::Val>,
impl<Head, Tail> SoundParser for Implicit<Head, Tail>where
Head: SoundParser,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: SoundParser<T = Tail::Val>,
Source§impl<Head, Tail> SpecByteLen for Implicit<Head, Tail>where
Head: SpecByteLen,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: SpecByteLen<T = Tail::Val>,
impl<Head, Tail> SpecByteLen for Implicit<Head, Tail>where
Head: SpecByteLen,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: SpecByteLen<T = Tail::Val>,
Source§impl<Head, Tail> SpecParser for Implicit<Head, Tail>where
Head: SpecParser,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: SpecParser<PVal = Tail::Val>,
impl<Head, Tail> SpecParser for Implicit<Head, Tail>where
Head: SpecParser,
Tail: DepCombinator<Key = Head::PVal>,
Tail::Body: SpecParser<PVal = Tail::Val>,
Source§open spec fn spec_parse(&self, ibuf: Seq<u8>) -> Option<(int, Self::PVal)>
open spec fn spec_parse(&self, ibuf: Seq<u8>) -> Option<(int, Self::PVal)>
{
match self.0.spec_parse(ibuf) {
Some((n1, key)) => {
let body = self.1.apply(key);
match body.spec_parse(ibuf.skip(n1)) {
Some((n2, value)) => Some((n1 + n2, value)),
None => None,
}
}
None => None,
}
}Source§type PVal = <Tail as DepCombinator>::Val
type PVal = <Tail as DepCombinator>::Val
The type of parsed values.
Source§impl<Head, Tail> SpecSerializer for Implicit<Head, Tail>where
Head: SpecSerializer,
Tail: DepCombinator<Key = Head::SVal>,
Tail::Body: SpecSerializer<SVal = Tail::Val>,
impl<Head, Tail> SpecSerializer for Implicit<Head, Tail>where
Head: SpecSerializer,
Tail: DepCombinator<Key = Head::SVal>,
Tail::Body: SpecSerializer<SVal = Tail::Val>,
Source§open spec fn spec_serialize(&self, value: Self::SVal) -> Seq<u8>
open spec fn spec_serialize(&self, value: Self::SVal) -> Seq<u8>
{
let key = self.1.recover(value);
let body = self.1.apply(key);
self.0.spec_serialize(key) + body.spec_serialize(value)
}Source§type SVal = <Tail as DepCombinator>::Val
type SVal = <Tail as DepCombinator>::Val
The type of values to be serialized.
Source§impl<Head, Tail> SpecSerializerDps for Implicit<Head, Tail>where
Head: SpecSerializerDps,
Tail: DepCombinator<Key = Head::SValue>,
Tail::Body: SpecSerializerDps<SValue = Tail::Val>,
impl<Head, Tail> SpecSerializerDps for Implicit<Head, Tail>where
Head: SpecSerializerDps,
Tail: DepCombinator<Key = Head::SValue>,
Tail::Body: SpecSerializerDps<SValue = Tail::Val>,
Source§open spec fn spec_serialize_dps(&self, value: Self::SValue, obuf: Seq<u8>) -> Seq<u8>
open spec fn spec_serialize_dps(&self, value: Self::SValue, obuf: Seq<u8>) -> Seq<u8>
{
let key = self.1.recover(value);
let body = self.1.apply(key);
self.0.spec_serialize_dps(key, body.spec_serialize_dps(value, obuf))
}Source§type SValue = <Tail as DepCombinator>::Val
type SValue = <Tail as DepCombinator>::Val
The type of values to be serialized.
Source§impl<Head, Tail> StaticByteLen for Implicit<Head, Tail>where
Head: StaticByteLen,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: StaticByteLen<T = Tail::Val>,
impl<Head, Tail> StaticByteLen for Implicit<Head, Tail>where
Head: StaticByteLen,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: StaticByteLen<T = Tail::Val>,
Source§open spec fn static_byte_len() -> nat
open spec fn static_byte_len() -> nat
{ Head::static_byte_len() + Tail::Body::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<Head, Tail> ValueByteLen for Implicit<Head, Tail>where
Head: StaticByteLen,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: ValueByteLen<T = Tail::Val>,
impl<Head, Tail> ValueByteLen for Implicit<Head, Tail>where
Head: StaticByteLen,
Tail: DepCombinator<Key = Head::T>,
Tail::Body: ValueByteLen<T = Tail::Val>,
Source§open spec fn value_byte_len(value: Self::T) -> nat
open spec fn value_byte_len(value: Self::T) -> nat
{ Head::static_byte_len() + Tail::Body::value_byte_len(value) }Source§proof fn lemma_value_len_matches_byte_len(&self, value: Self::T)
proof fn lemma_value_len_matches_byte_len(&self, value: Self::T)
impl<Head: Copy, Tail: Copy> Copy for Implicit<Head, Tail>
Auto Trait Implementations§
impl<Head, Tail> Freeze for Implicit<Head, Tail>
impl<Head, Tail> RefUnwindSafe for Implicit<Head, Tail>where
Head: RefUnwindSafe,
Tail: RefUnwindSafe,
impl<Head, Tail> Send for Implicit<Head, Tail>
impl<Head, Tail> Sync for Implicit<Head, Tail>
impl<Head, Tail> Unpin for Implicit<Head, Tail>
impl<Head, Tail> UnsafeUnpin for Implicit<Head, Tail>where
Head: UnsafeUnpin,
Tail: UnsafeUnpin,
impl<Head, Tail> UnwindSafe for Implicit<Head, Tail>where
Head: UnwindSafe,
Tail: 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() }