pub trait StackValue: Copy {
type Storage;
// Required methods
fn from_storage(value: Self::Storage) -> Result<Self>;
fn into_storage(self) -> Self::Storage;
// Provided methods
fn pop_from(source: &mut impl PopStack<Self::Storage>) -> Result<Self> { ... }
fn push_to(self, destination: &mut impl PushStack<Self::Storage>) { ... }
}Expand description
One copied logical stack value and its storage-representation conversions.
Separates the type a component computes with from the representation used to
access program storage. A component can declare operands such as
PopFromStack<(i64, f64)> and receive ordinary Rust values, while
vihaco_stdlib::ExecutionState decides how to store them. A later optimized
cursor can keep a floating-point value in a native cache without changing
that component’s messages or effects.
This trait is framework plumbing; ordinary component authors do not implement
it or any stack access logic.
Conversions describe one logical value and have no stack access. The default readers/writers consume/produce exactly one value through those conversions. Custom items need not have a Word encoding. This trait does not select an output storage bank or require native float insertion to pass through Word.
Booleans decode zero as false and every nonzero word as true. Insertion
normalizes them to 0 or 1; no canonical-input validation is performed.
Required Associated Types§
Sourcetype Storage
type Storage
The value representation exchanged with the program’s storage machinery.
Built-in integers and booleans use [Word]; floats use their native
types. For example, components compute with bool, while its storage
access uses an encoded Word. An f64 stays an f64 at this interface:
word-backed storage encodes its bits, while an optimized cursor can retain
the native value and avoid conversions between instructions.
“Storage” describes this internal access representation, not a physical memory location, allocation, or bytecode encoding. It lets program storage evolve independently of the component-facing operand/result types. The selected runtime cache bank remains the storage implementation’s concern.
Required Methods§
Sourcefn from_storage(value: Self::Storage) -> Result<Self>
fn from_storage(value: Self::Storage) -> Result<Self>
Convert one stored representation into a component-facing value.
§Errors
Returns any value-validation error required by a custom item. Built-in conversions accept every input, including truthy Boolean words.
Sourcefn into_storage(self) -> Self::Storage
fn into_storage(self) -> Self::Storage
Convert this value into the representation accepted by program storage.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".