Struct WriteVar

Source
pub struct WriteVar<T, C = VarNotClaimed>{ /* private fields */ }
Expand description

Write a value into a flowey Var at runtime, which can then be read via a corresponding ReadVar.

Vars in flowey must be serde de/serializable, in order to be de/serialized between multiple steps/nodes.

In order to write a value into a WriteVar, it must first be claimed by a particular step (using the ClaimVar::claim API). Once claimed, the Var can be written to using APIs such as RustRuntimeServices::write, or AdoStepServices::set_var

Note that it is only possible to write a value into a WriteVar once. Once the value has been written, the WriteVar type is immediately consumed, making it impossible to overwrite the stored value at some later point in execution.

This “write-once” property is foundational to flowey’s execution model, as by recoding what step wrote to a Var, and what step(s) read from the Var, it is possible to infer what order steps must be run in.

Implementations§

Source§

impl<T> WriteVar<T>

Source

pub fn new_reader(&self) -> ReadVar<T>

Create a new ReadVar from this WriteVar handle.

Source

pub fn write_static(self, ctx: &mut NodeCtx<'_>, val: T)
where T: 'static,

Write a static value into the Var.

Source§

impl<T, C> WriteVar<T, C>

Source

pub fn is_secret(&self) -> bool

Return whether the WriteVar is a secret.

Trait Implementations§

Source§

impl<T> ClaimVar for WriteVar<T>

Source§

type Claimed = WriteVar<T, VarClaimed>

The claimed version of Self.
Source§

fn claim(self, ctx: &mut StepCtx<'_>) -> WriteVar<T, VarClaimed>

Claim the Var for this step, allowing it to be accessed at runtime.
Source§

impl<T, C> Debug for WriteVar<T, C>

Source§

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

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

impl<'de, T, C> Deserialize<'de> for WriteVar<T, C>

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<WriteVar<T, C>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, C> Serialize for WriteVar<T, C>

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> VarEqBacking for WriteVar<T>

Source§

fn eq(&self, other: &WriteVar<T>) -> bool

Check if self is backed by the same variable as other.

Auto Trait Implementations§

§

impl<T, C> Freeze for WriteVar<T, C>

§

impl<T, C> RefUnwindSafe for WriteVar<T, C>

§

impl<T, C> Send for WriteVar<T, C>
where T: Send, C: Send,

§

impl<T, C> Sync for WriteVar<T, C>
where T: Sync, C: Sync,

§

impl<T, C> Unpin for WriteVar<T, C>
where T: Unpin, C: Unpin,

§

impl<T, C> UnwindSafe for WriteVar<T, C>
where T: UnwindSafe, C: 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.

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, 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,