Skip to main content

FnPrepare

Struct FnPrepare 

Source
pub struct FnPrepare<T: DeepView + ?Sized, Spec: SpecByteLen<T = T::V> + Consistency<Val = T::V>, Exec: Fn(&T) -> Result<usize, PreSerializeError>> {
    pub exec_fn: Exec,
    pub spec_fn: Ghost<Spec>,
    pub _marker: PhantomData<T>,
}
Expand description

Pairs an executable preparation closure with its consistency and byte-length specification.

Fields§

§exec_fn: Exec§spec_fn: Ghost<Spec>§_marker: PhantomData<T>

Implementations§

Source§

impl<T, Spec, Exec> FnPrepare<T, Spec, Exec>
where T: DeepView + ?Sized, Spec: SpecByteLen<T = T::V> + Consistency<Val = T::V>, Exec: Fn(&T) -> Result<usize, PreSerializeError>,

Source

pub exec fn new(exec_fn: Exec, Ghost(spec_fn): Ghost<Spec>) -> prepare : Self

requires
forall |value: &T| #[trigger] call_requires(exec_fn, (value,)),
forall |value: &T, result: Result<usize, PreSerializeError>| {
    #[trigger] call_ensures(exec_fn, (value,), result)
        ==> (result matches Ok(
            len,
        ) ==> {
            &&& spec_fn.consistent(value.deep_view())
            &&& len == spec_fn.byte_len(value.deep_view())

        })
},
ensures
prepare.exec_inv(),
prepare.spec_fn == spec_fn,

Trait Implementations§

Source§

impl<T, Spec, Exec> Consistency for FnPrepare<T, Spec, Exec>
where T: DeepView + ?Sized, Spec: SpecByteLen<T = T::V> + Consistency<Val = T::V>, Exec: Fn(&T) -> Result<usize, PreSerializeError>,

Source§

open spec fn consistent(&self, value: Self::Val) -> bool

{ self.spec_fn@.consistent(value) }
Source§

type Val = <T as DeepView>::V

The type of values whose consistency is being checked.
Source§

impl<T, Spec, Exec> Prepare<T> for FnPrepare<T, Spec, Exec>
where T: DeepView + ?Sized, Spec: SpecByteLen<T = T::V> + Consistency<Val = T::V>, Exec: Fn(&T) -> Result<usize, PreSerializeError>,

Source§

open spec fn exec_inv(&self) -> bool

{
    &&& forall |value: &T| #[trigger] call_requires(self.exec_fn, (value,))
    &&& forall |value: &T, result: Result<usize, PreSerializeError>| {
        #[trigger] call_ensures(self.exec_fn, (value,), result)
            ==> (result matches Ok(
                len,
            ) ==> {
                &&& self.spec_fn@.consistent(value.deep_view())
                &&& len == self.spec_fn@.byte_len(value.deep_view())

            })
    }

}
Source§

exec fn prepare(&self, value: &T) -> Result<usize, PreSerializeError>

Source§

impl<T, Spec, Exec> SpecByteLen for FnPrepare<T, Spec, Exec>
where T: DeepView + ?Sized, Spec: SpecByteLen<T = T::V> + Consistency<Val = T::V>, Exec: Fn(&T) -> Result<usize, PreSerializeError>,

Source§

open spec fn byte_len(&self, value: Self::T) -> nat

{ self.spec_fn@.byte_len(value) }
Source§

type T = <T as DeepView>::V

The type of values whose byte length is being computed.

Auto Trait Implementations§

§

impl<T, Spec, Exec> Freeze for FnPrepare<T, Spec, Exec>
where Exec: Freeze, T: ?Sized,

§

impl<T, Spec, Exec> RefUnwindSafe for FnPrepare<T, Spec, Exec>
where Exec: RefUnwindSafe, T: RefUnwindSafe + ?Sized, Spec: RefUnwindSafe,

§

impl<T, Spec, Exec> Send for FnPrepare<T, Spec, Exec>
where Exec: Send, T: Send + ?Sized,

§

impl<T, Spec, Exec> Sync for FnPrepare<T, Spec, Exec>
where Exec: Sync, T: Sync + ?Sized,

§

impl<T, Spec, Exec> Unpin for FnPrepare<T, Spec, Exec>
where Exec: Unpin, T: Unpin + ?Sized, Spec: Unpin,

§

impl<T, Spec, Exec> UnsafeUnpin for FnPrepare<T, Spec, Exec>
where Exec: UnsafeUnpin, T: ?Sized,

§

impl<T, Spec, Exec> UnwindSafe for FnPrepare<T, Spec, Exec>
where Exec: UnwindSafe, T: UnwindSafe + ?Sized, Spec: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, VERUS_SPEC__A> FromSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: From<T>,

§

fn obeys_from_spec() -> bool

§

fn from_spec(v: T) -> VERUS_SPEC__A

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, VERUS_SPEC__A> IntoSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: Into<T>,

§

fn obeys_into_spec() -> bool

§

fn into_spec(self) -> T

§

impl<T, U> IntoSpecImpl<U> for T
where U: From<T>,

§

fn obeys_into_spec() -> bool

§

fn into_spec(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: TryFrom<T>,

§

fn obeys_try_from_spec() -> bool

§

fn try_from_spec( v: T, ) -> Result<VERUS_SPEC__A, <VERUS_SPEC__A as TryFrom<T>>::Error>

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: TryInto<T>,

§

fn obeys_try_into_spec() -> bool

§

fn try_into_spec(self) -> Result<T, <VERUS_SPEC__A as TryInto<T>>::Error>

§

impl<T, U> TryIntoSpecImpl<U> for T
where U: TryFrom<T>,

§

fn obeys_try_into_spec() -> bool

§

fn try_into_spec(self) -> Result<U, <U as TryFrom<T>>::Error>

§

impl<A> SpecEq<&A> for A
where A: ?Sized,

§

impl<A> SpecEq<&mut A> for A
where A: ?Sized,

§

impl<A> SpecEq<A> for A
where A: ?Sized,

§

impl<A> SpecEq<Ghost<A>> for A

§

impl<A> SpecEq<Tracked<A>> for A