pub enum Value {
}Variants§
Void(())
I8(i8)
I16(i16)
I32(i32)
I64(i64)
I128(i128)
U8(u8)
U16(u16)
U32(u32)
U64(u64)
U128(u128)
F32(f32)
F64(f64)
Bool(bool)
Byte(u8)
Char(char)
String(String)
Vec(Vec<Value>)
Option(Option<Box<Value>>)
Packed(PackedArray)
Packed counterpart of Vec(Vec<Value>) for a homogeneous scalar array — see
PackedArray and ticket #116. Purely a representation choice: datatype()
reports the same DataType::Vec(...) either way.
Data(Arc<dyn Data>)
Implementations§
Source§impl Value
impl Value
pub fn datatype(&self) -> DataType
Sourcepub fn try_data<T>(self) -> Result<T, ()>
pub fn try_data<T>(self) -> Result<T, ()>
Casts to T, e.g. value.try_data::<HttpStatus>(). A thin forward to GetData,
but as an inherent method with T on the method rather than the trait, so the
turbofish goes where callers naturally reach for it and GetData doesn’t need to
be imported just to call this directly (outside a generic context where T is
already fixed, e.g. InputExt::recv_one_as, this was previously only reachable via
the more awkward GetData::<T>::try_data(value)).
Sourcepub fn estimated_size(&self) -> usize
pub fn estimated_size(&self) -> usize
Rough memory footprint of this value, in bytes.
Used to bound how much data a transmission buffer accumulates before flushing
(see melodium-engine’s Output), so it favors being cheap to compute over being
exact. Every Value occupies size_of::<Value>() inline regardless of variant
(the enum is sized for its largest payload) plus whatever content it owns on the
heap; Data has no cheap way to know its real size without serializing it, so a
conservative fixed estimate stands in for it.
Trait Implementations§
Source§impl DataTrait for Value
impl DataTrait for Value
fn to_i8(&self) -> i8
fn to_i16(&self) -> i16
fn to_i32(&self) -> i32
fn to_i64(&self) -> i64
fn to_i128(&self) -> i128
fn to_u8(&self) -> u8
fn to_u16(&self) -> u16
fn to_u32(&self) -> u32
fn to_u64(&self) -> u64
fn to_u128(&self) -> u128
fn to_f32(&self) -> f32
fn to_f64(&self) -> f64
fn to_bool(&self) -> bool
fn to_byte(&self) -> u8
fn to_char(&self) -> char
fn to_string(&self) -> String
fn try_to_i8(&self) -> Option<i8>
fn try_to_i16(&self) -> Option<i16>
fn try_to_i32(&self) -> Option<i32>
fn try_to_i64(&self) -> Option<i64>
fn try_to_i128(&self) -> Option<i128>
fn try_to_u8(&self) -> Option<u8>
fn try_to_u16(&self) -> Option<u16>
fn try_to_u32(&self) -> Option<u32>
fn try_to_u64(&self) -> Option<u64>
fn try_to_u128(&self) -> Option<u128>
fn try_to_f32(&self) -> Option<f32>
fn try_to_f64(&self) -> Option<f64>
fn try_to_bool(&self) -> Option<bool>
fn try_to_byte(&self) -> Option<u8>
fn try_to_char(&self) -> Option<char>
fn try_to_string(&self) -> Option<String>
fn saturating_to_i8(&self) -> i8
fn saturating_to_i16(&self) -> i16
fn saturating_to_i32(&self) -> i32
fn saturating_to_i64(&self) -> i64
fn saturating_to_i128(&self) -> i128
fn saturating_to_u8(&self) -> u8
fn saturating_to_u16(&self) -> u16
fn saturating_to_u32(&self) -> u32
fn saturating_to_u64(&self) -> u64
fn saturating_to_u128(&self) -> u128
fn saturating_to_f32(&self) -> f32
fn saturating_to_f64(&self) -> f64
fn binary_and(&self, other: &Value) -> Value
fn binary_or(&self, other: &Value) -> Value
fn binary_xor(&self, other: &Value) -> Value
fn binary_not(&self) -> Value
fn signed_abs(&self) -> Option<Value>
fn signed_signum(&self) -> Value
fn signed_is_positive(&self) -> bool
fn signed_is_negative(&self) -> bool
fn float_is_nan(&self) -> bool
fn float_is_infinite(&self) -> bool
fn float_is_finite(&self) -> bool
fn float_is_normal(&self) -> bool
fn float_is_subnormal(&self) -> bool
fn float_floor(&self) -> Value
fn float_ceil(&self) -> Value
fn float_round(&self) -> Value
fn float_trunc(&self) -> Value
fn float_fract(&self) -> Value
fn float_recip(&self) -> Value
fn float_pow(&self, n: &Value) -> Value
fn float_sqrt(&self) -> Value
fn float_exp(&self) -> Value
fn float_exp2(&self) -> Value
fn float_ln(&self) -> Value
fn float_log(&self, base: &Value) -> Value
fn float_log2(&self) -> Value
fn float_log10(&self) -> Value
fn float_cbrt(&self) -> Value
fn float_hypot(&self, n: &Value) -> Value
fn float_sin(&self) -> Value
fn float_cos(&self) -> Value
fn float_tan(&self) -> Value
fn float_asin(&self) -> Value
fn float_acos(&self) -> Value
fn float_atan(&self) -> Value
fn float_atan2(&self, n: &Value) -> Value
fn float_sinh(&self) -> Value
fn float_cosh(&self) -> Value
fn float_tanh(&self) -> Value
fn float_asinh(&self) -> Value
fn float_acosh(&self) -> Value
fn float_atanh(&self) -> Value
fn float_to_degrees(&self) -> Value
fn float_to_radians(&self) -> Value
fn partial_equality_eq(&self, other: &Value) -> bool
fn partial_equality_ne(&self, other: &Value) -> bool
fn partial_order_lt(&self, other: &Value) -> bool
fn partial_order_le(&self, other: &Value) -> bool
fn partial_order_gt(&self, other: &Value) -> bool
fn partial_order_ge(&self, other: &Value) -> bool
fn order_max(&self, other: &Value) -> Value
fn order_min(&self, other: &Value) -> Value
fn order_clamp(&self, min: &Value, max: &Value) -> Value
fn add(&self, other: &Value) -> Value
fn checked_add(&self, other: &Value) -> Option<Value>
fn saturating_add(&self, other: &Value) -> Value
fn wrapping_add(&self, other: &Value) -> Value
fn sub(&self, other: &Value) -> Value
fn checked_sub(&self, other: &Value) -> Option<Value>
fn saturating_sub(&self, other: &Value) -> Value
fn wrapping_sub(&self, other: &Value) -> Value
fn mul(&self, other: &Value) -> Value
fn checked_mul(&self, other: &Value) -> Option<Value>
fn saturating_mul(&self, other: &Value) -> Value
fn wrapping_mul(&self, other: &Value) -> Value
fn div(&self, other: &Value) -> Value
fn checked_div(&self, other: &Value) -> Option<Value>
fn rem(&self, other: &Value) -> Value
fn checked_rem(&self, other: &Value) -> Option<Value>
fn neg(&self) -> Value
fn checked_neg(&self) -> Option<Value>
fn wrapping_neg(&self) -> Value
fn pow(&self, exp: &u32) -> Value
fn checked_pow(&self, exp: &u32) -> Option<Value>
fn euclid_div(&self, other: &Value) -> Value
fn euclid_rem(&self, other: &Value) -> Value
fn checked_euclid_div(&self, other: &Value) -> Option<Value>
fn checked_euclid_rem(&self, other: &Value) -> Option<Value>
fn hash(&self, state: &mut dyn Hasher)
fn serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn display(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Source§impl<T> From<Arc<Vec<T>>> for Value
Direct bridge from an already-packed array to Value, for send_one_as/callers
that already hold an Arc<Vec<T>> (e.g. forwarding one received via
GetData<Arc<Vec<T>>> without ever unpacking it) — composes through PackedArray’s
own per-type From<Arc<Vec<T>>> impls, so it’s only available for Ts that are
actually packable.
impl<T> From<Arc<Vec<T>>> for Value
Direct bridge from an already-packed array to Value, for send_one_as/callers
that already hold an Arc<Vec<T>> (e.g. forwarding one received via
GetData<Arc<Vec<T>>> without ever unpacking it) — composes through PackedArray’s
own per-type From<Arc<Vec<T>>> impls, so it’s only available for Ts that are
actually packable.
Source§impl From<PackedArray> for Value
impl From<PackedArray> for Value
Source§fn from(value: PackedArray) -> Value
fn from(value: PackedArray) -> Value
Source§impl<D> GetData<Arc<D>> for Valuewhere
D: Data,
Casts straight to a concrete Data implementor, folding the two-step
GetData::<Arc<dyn Data>>::try_data(val).unwrap().downcast_arc::<D>().unwrap() idiom
(used throughout libs/*-mel for every custom data type) into one call — and, via
recv_one_as, into one non-panicking RecvResult. Coexists with the Arc<dyn Data>
impl above without conflict: D carries an implicit Sized bound here, which the
unsized dyn Data can never satisfy, so the two can never overlap for the same type.
impl<D> GetData<Arc<D>> for Valuewhere
D: Data,
Casts straight to a concrete Data implementor, folding the two-step
GetData::<Arc<dyn Data>>::try_data(val).unwrap().downcast_arc::<D>().unwrap() idiom
(used throughout libs/*-mel for every custom data type) into one call — and, via
recv_one_as, into one non-panicking RecvResult. Coexists with the Arc<dyn Data>
impl above without conflict: D carries an implicit Sized bound here, which the
unsized dyn Data can never satisfy, so the two can never overlap for the same type.
Source§impl GetData<Value> for Value
Identity extraction: a Value handed through unchanged. This is what an unconstrained
mel generic (#[mel_function] generic T (), or any bound not restricted to custom
Data types) actually resolves to at the Rust level — the macro type-aliases every
such generic name to Value itself — so Vec<T>/Option<T> involving a bare generic
need Self: GetData<T> to hold for T = Value in order to compose with the existing
blanket Vec/Option impls below, exactly like any other scalar type does.
impl GetData<Value> for Value
Identity extraction: a Value handed through unchanged. This is what an unconstrained
mel generic (#[mel_function] generic T (), or any bound not restricted to custom
Data types) actually resolves to at the Rust level — the macro type-aliases every
such generic name to Value itself — so Vec<T>/Option<T> involving a bare generic
need Self: GetData<T> to hold for T = Value in order to compose with the existing
blanket Vec/Option impls below, exactly like any other scalar type does.
Source§impl Serialize for Value
impl Serialize for Value
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Auto Trait Implementations§
impl !RefUnwindSafe for Value
impl !UnwindSafe for Value
impl Freeze for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§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>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§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.Source§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.