Skip to main content

PropValue

Enum PropValue 

Source
pub enum PropValue {
    Null,
    Bool(bool),
    F64(f64),
    I64(i64),
    U64(u64),
    Str(String),
    Array(Vec<PropValue>),
    Object(PropMap),
}
Expand description

A typed prop value. Covers all value types the widget system uses.

Mirrors JSON’s type system but without serde allocation overhead. Primitive values are stored inline (no boxing).

§Wire-canonical equality across numeric variants

JSON does not distinguish integer from float; the wire collapses 42 and 42.0 to the same on-wire shape. To keep diff/apply self-consistent across the wire, equality on PropValue treats I64(42), U64(42), and F64(42.0) as equal. Without this, tree_diff produces a spurious update_props op whenever a value passes through a numeric round-trip (animations interpolate to F64 while authored props start as I64, etc.).

Variants§

§

Null

Null.

§

Bool(bool)

Bool.

§

F64(f64)

F64.

§

I64(i64)

I64.

§

U64(u64)

U64.

§

Str(String)

Str.

§

Array(Vec<PropValue>)

Array.

§

Object(PropMap)

Object.

Implementations§

Source§

impl PropValue

Source

pub fn as_str(&self) -> Option<&str>

Borrow the value as a str.

Source

pub fn as_f64(&self) -> Option<f64>

Return the value as an f64 when conversion is finite and exact.

Source

pub fn as_bool(&self) -> Option<bool>

Borrow the value as a bool.

Source

pub fn as_i64(&self) -> Option<i64>

Return the value as an i64 when conversion is integral and in range.

Source

pub fn as_u64(&self) -> Option<u64>

Return the value as a u64 when conversion is integral and in range.

Source

pub fn as_array(&self) -> Option<&[PropValue]>

Borrow the value as an array.

Source

pub fn as_object(&self) -> Option<&PropMap>

Borrow the value as an object.

Source

pub fn is_null(&self) -> bool

Returns true when the null condition holds.

Trait Implementations§

Source§

impl Clone for PropValue

Source§

fn clone(&self) -> PropValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PropValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&str> for PropValue

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl From<PropValue> for Value

Source§

fn from(v: PropValue) -> Self

Converts to this type from the input type.
Source§

impl From<String> for PropValue

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for PropValue

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for PropValue

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for PropValue

Source§

fn from(v: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for PropValue

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for PropValue

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for PropValue

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for PropValue

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for PropValue

Source§

fn from(v: u64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for PropValue

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PlushieType for PropValue

Source§

fn wire_decode(value: &Value) -> Option<Self>

Decode from a wire-format JSON value.
Source§

fn wire_encode(&self) -> PropValue

Encode to PropValue for wire transport / direct mode.
Source§

fn type_name() -> &'static str

Wire type name for diagnostics.
Source§

fn extract(props: &Props, key: &str) -> Option<Self>

Extract this type from a Props store by key. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.