pub enum Value {
Null,
Bool(bool),
Int(i64),
Float(f64),
String(String),
List(Vec<Value>),
Map(HashMap<String, Value>),
Function(FunctionRef),
Bytes(Vec<u8>),
Error(String),
}Expand description
A Fusabi runtime value.
This is a representation of values that can be passed between the host and Fusabi scripts.
Variants§
Null
Null/nil value.
Bool(bool)
Boolean value.
Int(i64)
Integer value (64-bit signed).
Float(f64)
Floating point value (64-bit).
String(String)
UTF-8 string value.
List(Vec<Value>)
Ordered list of values.
Map(HashMap<String, Value>)
Key-value map (string keys).
Function(FunctionRef)
Opaque function reference (not directly usable by host).
Bytes(Vec<u8>)
Binary data.
Error(String)
Error value with message.
Implementations§
Source§impl Value
impl Value
Sourcepub fn deserialize<T>(self) -> Result<T, ValueConversionError>where
T: DeserializeOwned,
pub fn deserialize<T>(self) -> Result<T, ValueConversionError>where
T: DeserializeOwned,
Deserialize this Value into a serde-compatible type.
Sourcepub fn to_json_string(&self) -> String
pub fn to_json_string(&self) -> String
Convert to JSON string.
Sourcepub fn to_json_string_pretty(&self) -> String
pub fn to_json_string_pretty(&self) -> String
Convert to pretty JSON string.
Sourcepub fn from_json_str(s: &str) -> Result<Value, ValueConversionError>
pub fn from_json_str(s: &str) -> Result<Value, ValueConversionError>
Parse from JSON string.
Trait Implementations§
Source§impl FromValue for Value
impl FromValue for Value
Source§fn from_value(value: Value) -> Result<Value, ValueConversionError>
fn from_value(value: Value) -> Result<Value, ValueConversionError>
Convert from a Value, returning an error if conversion fails.
Source§fn from_value_ref(value: &Value) -> Result<Self, ValueConversionError>
fn from_value_ref(value: &Value) -> Result<Self, ValueConversionError>
Convert from a Value reference, cloning as needed.
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
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
Mutably borrows from an owned value. Read more