Control

Struct Control 

Source
pub struct Control<T: ?Sized> { /* private fields */ }
Expand description

Marks a variable as a state variable which can be used in conjunction with the until!-macro.

Whenever a control variable changes its value, the runtime system checks whether any other parts of the model are currently waiting for the variable to attain a certain value.

Implementations§

Source§

impl<T> Control<T>

Source

pub fn new(value: T) -> Self

Creates a new control variable and initializes its value.

Source

pub fn set(&self, val: T)

Assigns a new value to the control variable.

This can lead to potential activations of waiting processes.

Source

pub fn get(&self) -> T
where T: Copy,

Returns a copy of the stored inner value.

Source

pub fn swap(&self, other: &Self)

Swaps the values of two control variables. The difference to core::mem::swap is that this function doesn’t require an exclusive reference.

Source

pub fn replace(&self, val: T) -> T

Replaces the current value of the control variable with a new one and returns it.

This can lead to potential activations of waiting processes.

Source

pub fn update<F>(&self, f: F)
where F: FnOnce(T) -> T, T: Copy,

Updates the contained value using a function and returns the new value.

Source

pub fn take(&self) -> T
where T: Default,

Takes the value of the control variable, leaving Default::default() in its place.

Source

pub fn get_mut(&mut self) -> &mut T

Returns a mutable reference to the underlying data.

This call borrows the control variable mutably (at compile-time) which guarantees that we possess the only reference.

Source

pub fn unchecked_set(&self, val: T)

Assigns a new value to the control variable without notifying pending control conditions.

Use this method if you want to change the inner value without scheduling continuations that depend on it. Once finished, you may call notify directly.

Trait Implementations§

Source§

impl<T: Debug> Debug for Control<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Default + ?Sized> Default for Control<T>

Source§

fn default() -> Control<T>

Returns the “default value” for a type. Read more
Source§

impl<T: Display> Display for Control<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Copy> Expr for Control<T>

Source§

type Output = T

The result type.
Source§

fn get(&self) -> T

The routine used for evaluation.
Source§

impl<T: ?Sized> Publisher for Control<T>

The type of the object this notifier informs.
Source§

unsafe fn subscribe(&self, link: Pin<&Self::Link>)

Unsafely subscribes a link to the notifier. Read more
Source§

unsafe fn unsubscribe(&self, link: Pin<&Self::Link>)

Unsafely unsubscribes a link from the notifier. Read more
Source§

impl<T: ?Sized> Subscriber for Control<T>

Source§

fn notify(&self)

Notifies the object of a state change.

Auto Trait Implementations§

§

impl<T> !Freeze for Control<T>

§

impl<T> !RefUnwindSafe for Control<T>

§

impl<T> !Send for Control<T>

§

impl<T> !Sync for Control<T>

§

impl<T> Unpin for Control<T>
where T: Unpin + ?Sized,

§

impl<T> !UnwindSafe for Control<T>

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> ExprTerm for T
where T: Expr,

Source§

fn expr_term(&self) -> &Self

Trait method that is selected if the instance in question implements the Expr-trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

Source§

impl<T> PubTerm for T
where T: Publisher,

Source§

fn pub_term(&self) -> &Self

Trait method that is selected if the instance in question implements the Publisher-trait.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more