pub trait Update<R: RA> {
type Choice;
// Required methods
fn premise(self, from: R) -> bool;
fn update(self, from: R, ch: Self::Choice) -> R;
fn frame_preserving(self, from: R, frame: R) -> Self::Choice;
}Expand description
Perform an update on a resource.
This is used by Resource::update
to specify how to update a resource.
Required Associated Types§
Required Methods§
Sourcefn premise(self, from: R) -> bool
fn premise(self, from: R) -> bool
The premise of the update.
This must be true for the resource before applying the update.
logic ⚠
Sourcefn update(self, from: R, ch: Self::Choice) -> R
fn update(self, from: R, ch: Self::Choice) -> R
The actual update performed.
The content of the resource before the update is from. The update will
also choose some element ch of Choice to make the update with. The
return value will be the content of the resource after the update.
logic ⚠
requires
self.premise(from)Sourcefn frame_preserving(self, from: R, frame: R) -> Self::Choice
fn frame_preserving(self, from: R, frame: R) -> Self::Choice
Frame preservation.
This is a lemma that must be proven by implementors to ensure that the update is consistent.
It states that for any valid composition of self with some frame
resource, we can find a Choice that, when applying the corresponding
update, is still a valid composition with frame.
logic ⚠
requires
self.premise(from)requires
from.op(frame) != Noneensures
self.update(from, result).op(frame) != NoneImplementations on Foreign Types§
Source§impl<R1: RA, R2: RA, U1: Update<R1>, U2: Update<R2>> Update<(R1, R2)> for (U1, U2)
impl<R1: RA, R2: RA, U1: Update<R1>, U2: Update<R2>> Update<(R1, R2)> for (U1, U2)
Source§fn premise(self, from: (R1, R2)) -> bool
fn premise(self, from: (R1, R2)) -> bool
logic(open, inline)
self.0.premise(from.0) && self.1.premise(from.1)Source§fn update(self, from: (R1, R2), ch: (U1::Choice, U2::Choice)) -> (R1, R2)
fn update(self, from: (R1, R2), ch: (U1::Choice, U2::Choice)) -> (R1, R2)
logic(open, inline)
self.0.update(from.0, ch.0), self.1.update(from.1, ch.1)requires
self.premise(from)Source§fn frame_preserving(self, from: (R1, R2), frame: (R1, R2)) -> Self::Choice
fn frame_preserving(self, from: (R1, R2), frame: (R1, R2)) -> Self::Choice
logic ⚠
requires
self.premise(from)requires
from.op(frame) != Noneensures
self.update(from, result).op(frame) != Nonetype Choice = (<U1 as Update<R1>>::Choice, <U2 as Update<R2>>::Choice)
Implementors§
Source§impl<R: RA> Update<R> for Snapshot<R>
Apply a ‘raw’ update.
impl<R: RA> Update<R> for Snapshot<R>
Apply a ‘raw’ update.
This changes the state of the resource from one value to another. The premise of this change is that no existing composition with the resource is invalidated.
Source§impl<R: RA, Choice> Update<R> for Snapshot<Mapping<Choice, R>>
Apply a ‘raw’ non-deterministic update.
impl<R: RA, Choice> Update<R> for Snapshot<Mapping<Choice, R>>
Apply a ‘raw’ non-deterministic update.
This changes the state of the resource to one of the values of the mapping, non-deterministically.