OneLeftOwner

Struct OneLeftOwner 

Source
pub struct OneLeftOwner<A, B, const TOTAL: u64 = 2> { /* private fields */ }
Expand description

OneLeftOwner is a special case of Left that the fraction is always one and it is the resource owner.

Implementations§

Source§

impl<A, B, const TOTAL: u64> OneLeftOwner<A, B, TOTAL>

Source

pub closed spec fn id(self) -> Loc

Returns the unique identifier.

Source

pub closed spec fn protocol_monoid(self) -> CsumP<A, B, TOTAL>

The underlying protocol monoid value for this resource.

Source

pub closed spec fn resource(self) -> A

Returns the resource owned by this token.

Source

pub closed spec fn frac(self) -> int

Returns the fraction of this token, which should always be 1.

Source

pub closed spec fn has_resource(self) -> bool

Whether this token currently has the resource stored.

Source

pub closed spec fn has_no_resource(self) -> bool

Whether the resource has been taken from this token.

Source

pub open spec fn wf(self) -> bool

{
    &&& self.protocol_monoid().is_left()
    &&& self.protocol_monoid().is_valid()
    &&& self.protocol_monoid().is_resource_owner()
    &&& self.frac() == 1
    &&& TOTAL >= 1
    &&& self.has_resource() <==> !self.has_no_resource()

}

Type invariant.

Source

pub proof fn validate(tracked &self)

ensures
self.wf(),

OneLeftOwner token satisfies the type invariant.

Source

pub proof fn validate_with_one_left_owner(tracked &mut self, tracked other: &Self)

ensures
*old(self) == *self,
self.id() != other.id(),
self.wf(),

The existence of two OneLeftOwner tokens ensures they can not have the same id.

Source

pub proof fn tracked_borrow(tracked &self) -> tracked res : &A

requires
self.has_resource(),
ensures
*res == self.resource(),

Borrows the resource of type A.

Source

pub proof fn take_resource(tracked &mut self) -> tracked res : A

requires
old(self).has_resource(),
ensures
res == old(self).resource(),
self.has_no_resource(),
self.wf(),

Takes the resource out of the token.

Source

pub proof fn put_resource(tracked &mut self, tracked a: A)

requires
old(self).has_no_resource(),
ensures
self.resource() == a,
self.has_resource(),
self.wf(),

Puts a resource of type A back to the token.

Source

pub proof fn update(tracked &mut self, tracked a: A) -> tracked res : Option<A>

ensures
self.resource() == a,
self.has_resource(),
self.wf(),
res == if old(self).has_resource() { Some(old(self).resource()) } else { None },

Updates the resource of type A in the token, and returns the old resource if available.

Auto Trait Implementations§

§

impl<A, B, const TOTAL: u64> Freeze for OneLeftOwner<A, B, TOTAL>

§

impl<A, B, const TOTAL: u64> RefUnwindSafe for OneLeftOwner<A, B, TOTAL>

§

impl<A, B, const TOTAL: u64> Send for OneLeftOwner<A, B, TOTAL>
where A: Send + Sync, B: Send + Sync,

§

impl<A, B, const TOTAL: u64> Sync for OneLeftOwner<A, B, TOTAL>
where A: Sync + Send, B: Sync + Send,

§

impl<A, B, const TOTAL: u64> Unpin for OneLeftOwner<A, B, TOTAL>
where A: Unpin, B: Unpin,

§

impl<A, B, const TOTAL: u64> UnwindSafe for OneLeftOwner<A, B, TOTAL>
where A: UnwindSafe, B: 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>