pub enum Value {
Null,
Bool(bool),
I32(i32),
U32(u32),
F64(f64),
String(String),
Bytes(Vec<u8>),
Array(Vec<Value>),
Map(HashMap<String, Value>),
}Expand description
Dynamic type for Service API arguments and return values.
Allows passing data between plugins without knowing concrete types. Serialisable via serde for WASM boundary crossing.
Variants§
Null
No value / null.
Bool(bool)
Boolean.
I32(i32)
Signed 32-bit integer.
U32(u32)
Unsigned 32-bit integer (item_id, type_id).
F64(f64)
64-bit float (weight, distance).
String(String)
String (name, material, class).
Bytes(Vec<u8>)
Raw bytes (serialised ECS components, .ron files, etc.).
Array(Vec<Value>)
Array of values.
Map(HashMap<String, Value>)
Associative map / object with named fields.
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_u32(&self) -> Result<u32, ServiceError>
pub fn as_u32(&self) -> Result<u32, ServiceError>
Extract as u32.
Accepts U32, I32 (if >= 0), F64 (if integer and in range), and
parseable String.
Sourcepub fn as_i32(&self) -> Result<i32, ServiceError>
pub fn as_i32(&self) -> Result<i32, ServiceError>
Extract as i32.
Sourcepub fn as_f64(&self) -> Result<f64, ServiceError>
pub fn as_f64(&self) -> Result<f64, ServiceError>
Extract as f64.
Sourcepub fn as_str(&self) -> Result<&str, ServiceError>
pub fn as_str(&self) -> Result<&str, ServiceError>
Extract as &str.
Sourcepub fn as_bool(&self) -> Result<bool, ServiceError>
pub fn as_bool(&self) -> Result<bool, ServiceError>
Extract as bool.
Sourcepub fn as_bytes(&self) -> Result<&[u8], ServiceError>
pub fn as_bytes(&self) -> Result<&[u8], ServiceError>
Extract as &[u8].
Sourcepub fn as_array(&self) -> Result<&[Value], ServiceError>
pub fn as_array(&self) -> Result<&[Value], ServiceError>
Extract as &[Value].
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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 UnsafeUnpin 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