pub struct WriteVar<T: Serialize + DeserializeOwned, 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: Serialize + DeserializeOwned> WriteVar<T, VarNotClaimed>
impl<T: Serialize + DeserializeOwned> WriteVar<T, VarNotClaimed>
Sourcepub fn new_reader(&self) -> ReadVar<T>
pub fn new_reader(&self) -> ReadVar<T>
Sourcepub fn write_static(self, ctx: &mut NodeCtx<'_>, val: T)where
T: 'static,
pub fn write_static(self, ctx: &mut NodeCtx<'_>, val: T)where
T: 'static,
Write a static value into the Var.