pub struct Preceded<A, AVal, B, const CHECK: bool = false> {
pub a: A,
pub b: B,
pub a_val: AVal,
}Expand description
Parsing semantics: like (A, B), but discards the value parsed by A and returns only the value parsed by B.
Serialization semantics: reuses a_val as the serialized witness for A, then serializes B.
When CHECK is false, parsing is malleable in the discarded prefix unless A admits a unique consistent value.
When CHECK is true, parsing additionally checks that the parsed prefix equals a_val.
Fields§
§a: A§b: B§a_val: AValTrait Implementations§
Source§impl<A: Clone, AVal: Clone, B: Clone, const CHECK: bool> Clone for Preceded<A, AVal, B, CHECK>
impl<A: Clone, AVal: Clone, B: Clone, const CHECK: bool> Clone for Preceded<A, AVal, B, CHECK>
Source§exec fn clone(&self) -> cloned : Self
exec fn clone(&self) -> cloned : Self
ensures
call_ensures(A::clone, (&self.a,), cloned.a),call_ensures(B::clone, (&self.b,), cloned.b),call_ensures(AVal::clone, (&self.a_val,), cloned.a_val),1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<A, B, const CHECK: bool> Consistency for Preceded<A, A::Val, B, CHECK>where
A: Consistency,
B: Consistency,
impl<A, B, const CHECK: bool> Consistency for Preceded<A, A::Val, B, CHECK>where
A: Consistency,
B: Consistency,
Source§open spec fn consistent(&self, v: Self::Val) -> bool
open spec fn consistent(&self, v: Self::Val) -> bool
{
let fmt = preceded::<_, _, _, _, CHECK>(self.a, self.b, self.a_val);
fmt.consistent(v)
}Source§type Val = <B as Consistency>::Val
type Val = <B as Consistency>::Val
The type of values whose consistency is being checked.
Source§impl<A, B, const CHECK: bool> EquivSerializersGeneral for Preceded<A, A::SValue, B, CHECK>
impl<A, B, const CHECK: bool> EquivSerializersGeneral for Preceded<A, A::SValue, B, CHECK>
Source§open spec fn equiv_general_inv(&self) -> bool
open spec fn equiv_general_inv(&self) -> bool
{
let fmt = preceded::<_, _, _, _, CHECK>(self.a, self.b, self.a_val);
fmt.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<A, B, const CHECK: bool> GoodSerializer for Preceded<A, A::SVal, B, CHECK>where
A: GoodSerializer,
B: GoodSerializer,
impl<A, B, const CHECK: bool> GoodSerializer for Preceded<A, A::SVal, B, CHECK>where
A: GoodSerializer,
B: GoodSerializer,
Source§open spec fn serialize_inv(&self) -> bool
open spec fn serialize_inv(&self) -> bool
{
let fmt = preceded::<_, _, _, _, CHECK>(self.a, self.b, self.a_val);
fmt.serialize_inv()
}Source§proof fn lemma_serialize_len(&self, v: Self::SVal)
proof fn lemma_serialize_len(&self, v: Self::SVal)
Source§impl<A, B, const CHECK: bool> MinMaxByteLen for Preceded<A, A::T, B, CHECK>where
A: MinMaxByteLen,
B: MinMaxByteLen,
impl<A, B, const CHECK: bool> MinMaxByteLen for Preceded<A, A::T, B, CHECK>where
A: MinMaxByteLen,
B: MinMaxByteLen,
Source§impl<A, B, const CHECK: bool> NoLookAhead for Preceded<A, A::PVal, B, CHECK>where
A: NoLookAhead,
B: NoLookAhead,
impl<A, B, const CHECK: bool> NoLookAhead for Preceded<A, A::PVal, B, CHECK>where
A: NoLookAhead,
B: NoLookAhead,
Source§open spec fn no_lookahead_inv(&self) -> bool
open spec fn no_lookahead_inv(&self) -> bool
{
let fmt = preceded::<_, _, _, _, CHECK>(self.a, self.b, self.a_val);
fmt.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<A, B> NonMalleable for Preceded<A, A::PVal, B, false>
impl<A, B> NonMalleable for Preceded<A, A::PVal, B, false>
Source§open spec fn nonmal_inv(&self) -> bool
open spec fn nonmal_inv(&self) -> bool
{
&&& Pair(self.a, self.b).sound_inv()
&&& Pair(self.a, self.b).nonmal_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<A, B> NonMalleable for Preceded<A, A::PVal, B, true>
impl<A, B> NonMalleable for Preceded<A, A::PVal, B, true>
Source§open spec fn nonmal_inv(&self) -> bool
open spec fn nonmal_inv(&self) -> bool
{
&&& Pair(self.a, self.b).sound_inv()
&&& Pair(self.a, self.b).nonmal_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<A, B, const CHECK: bool> NonTailFmt for Preceded<A, A::SValue, B, CHECK>where
A: NonTailFmt,
B: NonTailFmt,
impl<A, B, const CHECK: bool> NonTailFmt for Preceded<A, A::SValue, B, CHECK>where
A: NonTailFmt,
B: NonTailFmt,
Source§open spec fn serialize_dps_inv(&self) -> bool
open spec fn serialize_dps_inv(&self) -> bool
{
let fmt = preceded::<_, _, _, _, CHECK>(self.a, self.b, self.a_val);
fmt.serialize_dps_inv()
}Source§proof fn lemma_serialize_dps_prepend(&self, v: Self::SValue, obuf: Seq<u8>)
proof fn lemma_serialize_dps_prepend(&self, v: Self::SValue, obuf: Seq<u8>)
Source§proof fn lemma_serialize_dps_len(&self, v: Self::SValue, obuf: Seq<u8>)
proof fn lemma_serialize_dps_len(&self, v: Self::SValue, obuf: Seq<u8>)
Source§impl<I, A, AVal, B> Parser<I> for Preceded<A, AVal, B, false>where
I: InputBuf,
A: Parser<I, PT = AVal> + SafeParser<PVal = AVal>,
B: Parser<I> + SafeParser,
AVal: DeepView<V = AVal>,
impl<I, A, AVal, B> Parser<I> for Preceded<A, AVal, B, false>where
I: InputBuf,
A: Parser<I, PT = AVal> + SafeParser<PVal = AVal>,
B: Parser<I> + SafeParser,
AVal: DeepView<V = AVal>,
Source§impl<I, A, AVal, B> Parser<I> for Preceded<A, AVal, B, true>where
I: InputBuf,
A: Parser<I, PT = AVal> + SafeParser<PVal = AVal>,
B: Parser<I> + SafeParser,
AVal: DeepView<V = AVal> + PartialEq + Structural,
impl<I, A, AVal, B> Parser<I> for Preceded<A, AVal, B, true>where
I: InputBuf,
A: Parser<I, PT = AVal> + SafeParser<PVal = AVal>,
B: Parser<I> + SafeParser,
AVal: DeepView<V = AVal> + PartialEq + Structural,
Source§impl<A, B> Productive for Preceded<A, A::PVal, B, false>where
A: Productive,
B: Productive,
impl<A, B> Productive for Preceded<A, A::PVal, B, false>where
A: Productive,
B: Productive,
Source§open spec fn productive_inv(&self) -> bool
open spec fn productive_inv(&self) -> bool
{ preceded::<_, _, _, _, false>(self.a, self.b, self.a_val).productive_inv() }Source§proof fn lemma_productive(&self, s: Seq<u8>)
proof fn lemma_productive(&self, s: Seq<u8>)
Source§impl<A, B> Productive for Preceded<A, A::PVal, B, true>where
A: Productive,
B: Productive,
impl<A, B> Productive for Preceded<A, A::PVal, B, true>where
A: Productive,
B: Productive,
Source§open spec fn productive_inv(&self) -> bool
open spec fn productive_inv(&self) -> bool
{ preceded::<_, _, _, _, true>(self.a, self.b, self.a_val).productive_inv() }Source§proof fn lemma_productive(&self, s: Seq<u8>)
proof fn lemma_productive(&self, s: Seq<u8>)
Source§impl<A, B, const CHECK: bool> SPRoundTripDps for Preceded<A, A::SValue, B, CHECK>
impl<A, B, const CHECK: bool> SPRoundTripDps for Preceded<A, A::SValue, B, CHECK>
Source§open spec fn unambiguous(&self) -> bool
open spec fn unambiguous(&self) -> bool
{ Pair(self.a, self.b).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<A, B, const CHECK: bool> SafeParser for Preceded<A, A::PVal, B, CHECK>where
A: SafeParser,
B: SafeParser,
impl<A, B, const CHECK: bool> SafeParser for Preceded<A, A::PVal, B, CHECK>where
A: SafeParser,
B: SafeParser,
Source§impl<Output: OutputBuf, A, AVal, B, T, const CHECK: bool> Serializer<Output, T> for Preceded<A, AVal, B, CHECK>where
AVal: DeepView<V = AVal>,
T: DeepView,
A: Serializer<Output, AVal>,
B: Serializer<Output, T>,
impl<Output: OutputBuf, A, AVal, B, T, const CHECK: bool> Serializer<Output, T> for Preceded<A, AVal, B, CHECK>where
AVal: DeepView<V = AVal>,
T: DeepView,
A: Serializer<Output, AVal>,
B: Serializer<Output, T>,
Source§open spec fn exec_inv(&self) -> bool
open spec fn exec_inv(&self) -> bool
{
&&& self.a.exec_inv()
&&& self.b.exec_inv()
&&& forall |v: AVal| v.deep_view() == v
}Source§exec fn serialize_into(&self, v: &T, obuf: &mut Output)
exec fn serialize_into(&self, v: &T, obuf: &mut Output)
Source§impl<A, B> SoundParser for Preceded<A, A::PVal, B, false>
impl<A, B> SoundParser for Preceded<A, A::PVal, B, false>
Source§impl<A, B> SoundParser for Preceded<A, A::PVal, B, true>where
A: SoundParser,
B: SoundParser,
impl<A, B> SoundParser for Preceded<A, A::PVal, B, true>where
A: SoundParser,
B: SoundParser,
Source§impl<A, B, const CHECK: bool> SpecByteLen for Preceded<A, A::T, B, CHECK>where
A: SpecByteLen,
B: SpecByteLen,
impl<A, B, const CHECK: bool> SpecByteLen for Preceded<A, A::T, B, CHECK>where
A: SpecByteLen,
B: SpecByteLen,
Source§impl<A, B, const CHECK: bool> SpecParser for Preceded<A, A::PVal, B, CHECK>where
A: SpecParser,
B: SpecParser,
impl<A, B, const CHECK: bool> SpecParser for Preceded<A, A::PVal, B, CHECK>where
A: SpecParser,
B: SpecParser,
Source§impl<A, B, const CHECK: bool> SpecSerializer for Preceded<A, A::SVal, B, CHECK>where
A: SpecSerializer,
B: SpecSerializer,
impl<A, B, const CHECK: bool> SpecSerializer for Preceded<A, A::SVal, B, CHECK>where
A: SpecSerializer,
B: SpecSerializer,
Source§open spec fn spec_serialize(&self, v: Self::SVal) -> Seq<u8>
open spec fn spec_serialize(&self, v: Self::SVal) -> Seq<u8>
{
let fmt = preceded::<_, _, _, _, CHECK>(self.a, self.b, self.a_val);
fmt.spec_serialize(v)
}Source§type SVal = <B as SpecSerializer>::SVal
type SVal = <B as SpecSerializer>::SVal
The type of values to be serialized.
Source§impl<A, B, const CHECK: bool> SpecSerializerDps for Preceded<A, A::SValue, B, CHECK>where
A: SpecSerializerDps,
B: SpecSerializerDps,
impl<A, B, const CHECK: bool> SpecSerializerDps for Preceded<A, A::SValue, B, CHECK>where
A: SpecSerializerDps,
B: SpecSerializerDps,
Source§impl<A, B, const CHECK: bool> StaticByteLen for Preceded<A, A::T, B, CHECK>where
A: StaticByteLen,
B: StaticByteLen,
impl<A, B, const CHECK: bool> StaticByteLen for Preceded<A, A::T, B, CHECK>where
A: StaticByteLen,
B: StaticByteLen,
Source§open spec fn static_byte_len() -> nat
open spec fn static_byte_len() -> nat
{ <Pair<A, B> as StaticByteLen>::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<A, B, const CHECK: bool> ValueByteLen for Preceded<A, A::T, B, CHECK>where
A: StaticByteLen,
B: ValueByteLen,
impl<A, B, const CHECK: bool> ValueByteLen for Preceded<A, A::T, B, CHECK>where
A: StaticByteLen,
B: ValueByteLen,
Source§open spec fn value_byte_len(v: Self::T) -> nat
open spec fn value_byte_len(v: Self::T) -> nat
{ A::static_byte_len() + B::value_byte_len(v) }Source§proof fn lemma_value_len_matches_byte_len(&self, v: Self::T)
proof fn lemma_value_len_matches_byte_len(&self, v: Self::T)
impl<A: Copy, AVal: Copy, B: Copy, const CHECK: bool> Copy for Preceded<A, AVal, B, CHECK>
Auto Trait Implementations§
impl<A, AVal, B, const CHECK: bool> Freeze for Preceded<A, AVal, B, CHECK>
impl<A, AVal, B, const CHECK: bool> RefUnwindSafe for Preceded<A, AVal, B, CHECK>
impl<A, AVal, B, const CHECK: bool> Send for Preceded<A, AVal, B, CHECK>
impl<A, AVal, B, const CHECK: bool> Sync for Preceded<A, AVal, B, CHECK>
impl<A, AVal, B, const CHECK: bool> Unpin for Preceded<A, AVal, B, CHECK>
impl<A, AVal, B, const CHECK: bool> UnsafeUnpin for Preceded<A, AVal, B, CHECK>
impl<A, AVal, B, const CHECK: bool> UnwindSafe for Preceded<A, AVal, B, CHECK>
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() }