Enum biodivine_sketchbook::app::state::Consumed

source ·
pub enum Consumed {
    Reversible {
        state_change: Event,
        perform_reverse: (Event, Event),
    },
    Irreversible {
        state_change: Event,
        reset: bool,
    },
    Restart(Vec<Event>),
    InputError(DynError),
    NoChange,
}
Expand description

A Consumed object describes possible outcomes of trying to consume an Event by some session state object.

Variants§

§

Reversible

Event was successfully consumed, resulting the provided state_change Event.

Furthermore, the operation is reversible. This means it can be save to the back-stack as a pair of (perform, reverse) events. Note that the perform event does not need to be the original event. For example, there could be automated normalization which won’t need to be repeated.

At the moment, each event must be reversible by a single event. If this is not the case, you can “restart” the evaluation process with a new, more granular event chain by returning Consumed::Restart. It is the responsibility of the session state to record this whole chain as a single reversible action.

However, note that this does not guarantee that the action will be saved to the undo stack. If the payloads for the (perform, reverse) actions are too large, session state can still refuse to save it, in which case the stack will be simply reset to empty. Finally, some sessions may not have an undo stack at all, in which case the (perform, reverse) pair is completely ignored.

Fields

§state_change: Event
§perform_reverse: (Event, Event)
§

Irreversible

Action was successfully consumed, resulting in the given state_change Event.

However, the action is irreversible. This means the undo stack should be either cleared if reset=true, or the action should bypass the stack completely if reset=false.

Fields

§state_change: Event
§reset: bool
§

Restart(Vec<Event>)

Action cannot be consumed as is and should be instead replaced by the provided list of events.

Note that the original event may or may not be a member of this list. In particular, if you want to retry the event, you have to manually copy it into the list.

You can use this result type to perform additional events that are necessary to execute before the original event can be completed safely. For example, if we want to delete a variable, we want to first delete all associated regulations.

§

InputError(DynError)

The action was consumed, but the provided user input is invalid and cannot be applied.

Note that this should only be used when the user input is wrong. If some other part of the action is wrong (e.g. unknown path, missing fields in payload), the action cannot be consumed!

§

NoChange

The action was consumed, but the application state did not change.

Trait Implementations§

source§

impl Debug for Consumed

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.

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> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T