pub trait TrackDrop: Sized {
type State;
type Obligation;
// Required methods
spec fn tracked_redeem_requires(self, s: Self::State) -> bool;
spec fn tracked_redeem_ensures(
self,
s0: Self::State,
s1: Self::State,
obl: Self::Obligation,
) -> bool;
proof fn tracked_redeem(self, tracked s: &mut Self::State) -> tracked obl : Self::Obligation;
spec fn drop_requires(self, s: Self::State, obl: Self::Obligation) -> bool;
spec fn drop_ensures(
self,
s0: Self::State,
s1: Self::State,
obl: Self::Obligation,
) -> bool;
}Expand description
A protocol for associating a value with a permission used by its verified drop implementation.
This trait only defines the shape of the protocol. Implementing it does not
by itself guarantee that TrackDrop::Obligation is linear, unforgeable,
or authoritatively tied to TrackDrop::State. In particular, an
implementation may intentionally use a trivial obligation and perform no
drop-permission checking.
Implementations that rely on this protocol for safety are responsible for establishing all of the following properties in their concrete specifications and proofs:
- an issued obligation is associated with the value for which it was issued;
- the obligation cannot be forged or duplicated;
- the state records enough authoritative information to detect a lost outstanding obligation; and
Drop::dropconsumes the obligation and performs the corresponding state transition exactly once.
Required Associated Types§
Sourcetype Obligation
type Obligation
The type of the drop permission.
This permission does not necessarily represent the full permission to
drop the value, as TrackDrop::drop_requires still takes a
TrackDrop::State parameter.
Required Methods§
Sourcespec fn tracked_redeem_requires(self, s: Self::State) -> bool
spec fn tracked_redeem_requires(self, s: Self::State) -> bool
Sourcespec fn tracked_redeem_ensures(
self,
s0: Self::State,
s1: Self::State,
obl: Self::Obligation,
) -> bool
spec fn tracked_redeem_ensures( self, s0: Self::State, s1: Self::State, obl: Self::Obligation, ) -> bool
Sourceproof fn tracked_redeem(self, tracked s: &mut Self::State) -> tracked obl : Self::Obligation
proof fn tracked_redeem(self, tracked s: &mut Self::State) -> tracked obl : Self::Obligation
self.tracked_redeem_requires(*old(s)),ensuresself.tracked_redeem_ensures(*old(s), *final(s), obl),Gives the drop permission to the value.
Sourcespec fn drop_requires(self, s: Self::State, obl: Self::Obligation) -> bool
spec fn drop_requires(self, s: Self::State, obl: Self::Obligation) -> bool
Precondition of Drop::drop.
Sourcespec fn drop_ensures(
self,
s0: Self::State,
s1: Self::State,
obl: Self::Obligation,
) -> bool
spec fn drop_ensures( self, s0: Self::State, s1: Self::State, obl: Self::Obligation, ) -> bool
Postcondition of Drop::drop.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.