pub struct Machine { /* private fields */ }Expand description
A linked program and its persistent state. Clone creates an independent checkpoint.
Implementations§
Source§impl Machine
impl Machine
Sourcepub fn new(program: Program, limits: Limits) -> Result<Self, Diagnostic>
pub fn new(program: Program, limits: Limits) -> Result<Self, Diagnostic>
Initialize supplied modules once in dependency order, then the main module.
§Errors
Rejects invalid initializers or resource limits without creating a machine.
Sourcepub fn with_registry(
program: Program,
limits: Limits,
registry: NativeRegistry,
) -> Result<Self, Diagnostic>
pub fn with_registry( program: Program, limits: Limits, registry: NativeRegistry, ) -> Result<Self, Diagnostic>
Sourcepub const fn execution_state(&self) -> (u64, bool)
pub const fn execution_state(&self) -> (u64, bool)
Returns the current fixed tick and terminal lifecycle state without cloning entities, logs, traces, or component values.
Sourcepub fn tick(&mut self, dt: f64) -> Result<Snapshot, Diagnostic>
pub fn tick(&mut self, dt: f64) -> Result<Snapshot, Diagnostic>
Run all systems in linked source order. A system visits its starting query
in ascending entity-ID order. Spawns are visible to subsequent systems.
New tuples run init immediately before their first frame. A despawn
request takes effect after the current callback writes its bindings back;
initialized tuples then run done before the entity is deleted.
§Errors
Any error rolls back the complete tick, including logs and entity IDs.
Sourcepub fn finish(&mut self) -> Result<Snapshot, Diagnostic>
pub fn finish(&mut self) -> Result<Snapshot, Diagnostic>
Complete initialized system memberships in system/entity/component order. Repeated calls return the same snapshot. No callback runs for an unvisited tuple.
§Errors
A failed callback rolls back all cleanup and keeps the machine running.
Sourcepub fn invoke(
&mut self,
name: &str,
arguments: Vec<Value>,
) -> Result<Value, Diagnostic>
pub fn invoke( &mut self, name: &str, arguments: Vec<Value>, ) -> Result<Value, Diagnostic>
Invoke a main or explicitly imported/exported function transactionally. This is the shared action entry for UI controls, tests, and agent adapters.
§Errors
Rejects inaccessible/unknown names, invalid arguments or execution, and exhausted budgets. The previously accepted state remains unchanged.
Sourcepub fn invoke_component(
&mut self,
id: u64,
component: &str,
field: &str,
arguments: Vec<Value>,
) -> Result<Value, Diagnostic>
pub fn invoke_component( &mut self, id: u64, component: &str, field: &str, arguments: Vec<Value>, ) -> Result<Value, Diagnostic>
Invoke the typed function stored in an exact component field. The host supplies no function identity; private callbacks retained by the program remain callable. Lookup, execution, logs and world edits commit together.
§Errors
Rejects missing entity/component/field, non-callable fields, mismatched arguments and exhausted budgets, preserving the accepted state.
Sourcepub fn invoke_entity(
&mut self,
id: u64,
name: &str,
arguments: Vec<Value>,
) -> Result<Value, Diagnostic>
pub fn invoke_entity( &mut self, id: u64, name: &str, arguments: Vec<Value>, ) -> Result<Value, Diagnostic>
Dispatch a method on exactly one component. Multiple matching components are ambiguous and rejected; mutation and logs commit together on success.
§Errors
Rejects missing/ambiguous methods, invalid arguments, conflicting component writes, and execution limits without changing accepted state.
Sourcepub fn upsert_components(
&mut self,
patches: &[(u64, Value)],
) -> Result<(), Diagnostic>
pub fn upsert_components( &mut self, patches: &[(u64, Value)], ) -> Result<(), Diagnostic>
Atomically attach or replace validated components from an explicit host adapter. Existing entity identity and spawn source are preserved.
§Errors
Rejects unknown entities, malformed records, and storage limit violations.
Sourcepub fn patch_components(
&mut self,
patches: &[(u64, Value)],
) -> Result<(), Diagnostic>
pub fn patch_components( &mut self, patches: &[(u64, Value)], ) -> Result<(), Diagnostic>
Atomically replace existing components from a host adapter (for example, a physics solver). Class fields and all storage limits are revalidated.
§Errors
Rejects missing entities/components, malformed records, and storage limits; either the complete patch is accepted or none of it is applied.
Sourcepub fn transaction<T>(
&mut self,
operation: impl FnOnce(&mut Self) -> Result<T, Diagnostic>,
) -> Result<T, Diagnostic>
pub fn transaction<T>( &mut self, operation: impl FnOnce(&mut Self) -> Result<T, Diagnostic>, ) -> Result<T, Diagnostic>
Roll back this machine when a composed operation fails.
§Errors
Propagates the closure diagnostic without replacing this machine. The closure must include any adapter state in its own transaction; this method cannot undo external I/O, global Rust state, or effects on other objects.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Machine
impl RefUnwindSafe for Machine
impl Send for Machine
impl Sync for Machine
impl Unpin for Machine
impl UnsafeUnpin for Machine
impl UnwindSafe for Machine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSync for T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.