pub struct Bits<Repr: SpecByteLen, Tuple, Nominal> {
pub repr: Repr,
pub unpack: FnSpec<(Repr::T,), Tuple>,
pub pack: FnSpec<(Tuple,), Repr::T>,
pub refinement: PredFnSpec<Tuple>,
pub ctor: FnSpec<(Tuple,), Nominal>,
pub dtor: FnSpec<(Nominal,), Tuple>,
pub consistent: PredFnSpec<Nominal>,
}Expand description
Packs a tuple of logical bitfield values into one fixed-width integer representation.
Generated Vest bitfield formats use the functions stored here to unpack the wire integer, validate the structural tuple, construct the public nominal value, and perform the inverse operation during serialization.
Fields§
§repr: ReprInteger format that reads and writes the complete bitfield word.
unpack: FnSpec<(Repr::T,), Tuple>Splits the representation into its structural field tuple.
pack: FnSpec<(Tuple,), Repr::T>Packs the structural field tuple into the representation.
refinement: PredFnSpec<Tuple>Predicate enforcing field widths and reserved-bit constraints.
ctor: FnSpec<(Tuple,), Nominal>Constructs the public nominal value from structural fields.
dtor: FnSpec<(Nominal,), Tuple>Projects a public nominal value back to structural fields.
consistent: PredFnSpec<Nominal>Additional consistency predicate for nominal values.
Trait Implementations§
Source§impl<Repr, Tuple, Nominal> Consistency for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> Consistency for Bits<Repr, Tuple, Nominal>
Source§impl<Repr, Tuple, Nominal> EquivSerializers for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> EquivSerializers for Bits<Repr, Tuple, Nominal>
Source§impl<Repr, Tuple, Nominal> EquivSerializersGeneral for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> EquivSerializersGeneral for Bits<Repr, Tuple, Nominal>
Source§open spec fn equiv_general_inv(&self) -> bool
open spec fn equiv_general_inv(&self) -> bool
{
let fmt = bits(
self.repr,
self.unpack,
self.pack,
self.refinement,
self.ctor,
self.dtor,
);
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<Repr, Tuple, Nominal> GoodSerializer for Bits<Repr, Tuple, Nominal>where
Repr: GoodSerializer,
impl<Repr, Tuple, Nominal> GoodSerializer for Bits<Repr, Tuple, Nominal>where
Repr: GoodSerializer,
Source§open spec fn serialize_inv(&self) -> bool
open spec fn serialize_inv(&self) -> bool
{
let fmt = bits(
self.repr,
self.unpack,
self.pack,
self.refinement,
self.ctor,
self.dtor,
);
fmt.serialize_inv()
}Source§proof fn lemma_serialize_len(&self, v: Self::SVal)
proof fn lemma_serialize_len(&self, v: Self::SVal)
Source§impl<Repr, Tuple, Nominal> MinMaxByteLen for Bits<Repr, Tuple, Nominal>where
Repr: MinMaxByteLen,
impl<Repr, Tuple, Nominal> MinMaxByteLen for Bits<Repr, Tuple, Nominal>where
Repr: MinMaxByteLen,
Source§open spec fn min(&self) -> nat
open spec fn min(&self) -> nat
{
let fmt = bits(
self.repr,
self.unpack,
self.pack,
self.refinement,
self.ctor,
self.dtor,
);
fmt.min()
}Source§open spec fn max(&self) -> nat
open spec fn max(&self) -> nat
{
let fmt = bits(
self.repr,
self.unpack,
self.pack,
self.refinement,
self.ctor,
self.dtor,
);
fmt.max()
}Source§proof fn lemma_min_max_byte_len(&self, v: Self::T)
proof fn lemma_min_max_byte_len(&self, v: Self::T)
Source§impl<Repr, Tuple, Nominal> NoLookAhead for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> NoLookAhead for Bits<Repr, Tuple, Nominal>
Source§open spec fn no_lookahead_inv(&self) -> bool
open spec fn no_lookahead_inv(&self) -> bool
{
let fmt = bits(
self.repr,
self.unpack,
self.pack,
self.refinement,
self.ctor,
self.dtor,
);
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<Repr, Tuple, Nominal> NonMalleable for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> NonMalleable for Bits<Repr, Tuple, Nominal>
Source§open spec fn nonmal_inv(&self) -> bool
open spec fn nonmal_inv(&self) -> bool
{
let fmt = bits(
self.repr,
self.unpack,
self.pack,
self.refinement,
self.ctor,
self.dtor,
);
fmt.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<Repr, Tuple, Nominal> NonTailFmt for Bits<Repr, Tuple, Nominal>where
Repr: NonTailFmt,
impl<Repr, Tuple, Nominal> NonTailFmt for Bits<Repr, Tuple, Nominal>where
Repr: NonTailFmt,
Source§open spec fn serialize_dps_inv(&self) -> bool
open spec fn serialize_dps_inv(&self) -> bool
{
let fmt = bits(
self.repr,
self.unpack,
self.pack,
self.refinement,
self.ctor,
self.dtor,
);
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<Repr, Tuple, Nominal> Productive for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> Productive for Bits<Repr, Tuple, Nominal>
Source§open spec fn productive_inv(&self) -> bool
open spec fn productive_inv(&self) -> bool
{
let fmt = bits(
self.repr,
self.unpack,
self.pack,
self.refinement,
self.ctor,
self.dtor,
);
fmt.productive_inv()
}Source§proof fn lemma_productive(&self, s: Seq<u8>)
proof fn lemma_productive(&self, s: Seq<u8>)
Source§impl<Repr, Tuple, Nominal> SPRoundTripDps for Bits<Repr, Tuple, Nominal>where
Repr: SPRoundTripDps,
impl<Repr, Tuple, Nominal> SPRoundTripDps for Bits<Repr, Tuple, Nominal>where
Repr: SPRoundTripDps,
Source§open spec fn unambiguous(&self) -> bool
open spec fn unambiguous(&self) -> bool
{
&&& self.repr.unambiguous()
&&& forall |unpacked: Tuple| {
(#[trigger] (self.consistent)((self.ctor)(unpacked))
&& (self.refinement)(unpacked))
==> (self.unpack)((self.pack)(unpacked)) == unpacked
}
&&& forall |t: Nominal| {
#[trigger] (self.consistent)(t) ==> (self.ctor)((self.dtor)(t)) == t
}
}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<Repr, Tuple, Nominal> SafeParser for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> SafeParser for Bits<Repr, Tuple, Nominal>
Source§impl<Repr, Tuple, Nominal> SoundParser for Bits<Repr, Tuple, Nominal>where
Repr: SoundParser,
impl<Repr, Tuple, Nominal> SoundParser for Bits<Repr, Tuple, Nominal>where
Repr: SoundParser,
Source§open spec fn sound_inv(&self) -> bool
open spec fn sound_inv(&self) -> bool
{
let fmt = bits(
self.repr,
self.unpack,
self.pack,
self.refinement,
self.ctor,
self.dtor,
);
&&& fmt.sound_inv()
&&& forall |ibuf| (
#[trigger]
fmt.spec_parse(ibuf) matches Some((_, v)) ==> (self.consistent)(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<Repr, Tuple, Nominal> SpecByteLen for Bits<Repr, Tuple, Nominal>where
Repr: SpecByteLen,
impl<Repr, Tuple, Nominal> SpecByteLen for Bits<Repr, Tuple, Nominal>where
Repr: SpecByteLen,
Source§impl<Repr, Tuple, Nominal> SpecParser for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> SpecParser for Bits<Repr, Tuple, Nominal>
Source§impl<Repr, Tuple, Nominal> SpecSerializer for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> SpecSerializer for Bits<Repr, Tuple, Nominal>
Source§impl<Repr, Tuple, Nominal> SpecSerializerDps for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> SpecSerializerDps for Bits<Repr, Tuple, Nominal>
Source§impl<Repr, Tuple, Nominal> StaticByteLen for Bits<Repr, Tuple, Nominal>where
Repr: StaticByteLen,
impl<Repr, Tuple, Nominal> StaticByteLen for Bits<Repr, Tuple, Nominal>where
Repr: StaticByteLen,
Source§open spec fn static_byte_len() -> nat
open spec fn static_byte_len() -> nat
{ Repr::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)
Auto Trait Implementations§
impl<Repr, Tuple, Nominal> Freeze for Bits<Repr, Tuple, Nominal>where
Repr: Freeze,
impl<Repr, Tuple, Nominal> RefUnwindSafe for Bits<Repr, Tuple, Nominal>where
Repr: RefUnwindSafe,
Tuple: RefUnwindSafe,
<Repr as SpecByteLen>::T: RefUnwindSafe,
Nominal: RefUnwindSafe,
impl<Repr, Tuple, Nominal> Send for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> Sync for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> Unpin for Bits<Repr, Tuple, Nominal>
impl<Repr, Tuple, Nominal> UnsafeUnpin for Bits<Repr, Tuple, Nominal>where
Repr: UnsafeUnpin,
impl<Repr, Tuple, Nominal> UnwindSafe for Bits<Repr, Tuple, Nominal>where
Repr: UnwindSafe,
Tuple: UnwindSafe,
<Repr as SpecByteLen>::T: UnwindSafe,
Nominal: 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<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() }