Skip to main content

Props

Struct Props 

Source
pub struct Props(/* private fields */);
Expand description

Prop storage for TreeNode.

Wraps a PropMap. Both direct-mode SDK builders and wire-mode JSON deserialisation land in the same representation; accessors are plain delegations with no per-variant branching.

Implementations§

Source§

impl Props

Source

pub fn from_json(value: Value) -> Self

Construct from a serde_json::Value. Non-object values (a stray string, number, etc.) become an empty PropMap rather than a panic, so malformed wire input degrades gracefully.

Source

pub fn get_str(&self, key: &str) -> Option<&str>

Get a string prop.

Source

pub fn get_f64(&self, key: &str) -> Option<f64>

Get a numeric prop as f64 when conversion is finite and exact.

Source

pub fn get_f32(&self, key: &str) -> Option<f32>

Get a numeric prop as f32 when conversion remains finite.

Source

pub fn get_bool(&self, key: &str) -> Option<bool>

Get a boolean prop.

Source

pub fn get_i64(&self, key: &str) -> Option<i64>

Get an integer prop as i64 when conversion is integral and in range.

Source

pub fn get_u64(&self, key: &str) -> Option<u64>

Get an unsigned integer prop as u64 when conversion is integral and in range.

Source

pub fn contains_key(&self, key: &str) -> bool

Check if a key exists.

Source

pub fn as_value_cow(&self) -> Cow<'_, Value>

Convert to a JSON Value for consumption by prop_helpers.

Always allocates (converts PropMap to JSON Map). Callers that only need field-by-field access should use the typed accessors directly instead.

Source

pub fn as_prop_map(&self) -> &PropMap

Borrow the underlying PropMap.

Source

pub fn as_prop_map_mut(&mut self) -> &mut PropMap

Mutably borrow the underlying PropMap.

Source

pub fn get(&self, key: &str) -> Option<&PropValue>

Get a prop by key as &PropValue.

Source

pub fn get_value(&self, key: &str) -> Option<Value>

Get a prop value as an owned Value. Allocates. Use sparingly; prefer the typed accessors (get_str, get_f64, etc.) when possible.

Source

pub fn to_value(&self) -> Value

Convert to a serde_json::Value (for wire serialization).

Source

pub fn is_object(&self) -> bool

True if the props contain an object/map structure. Always true for the unified representation.

Trait Implementations§

Source§

impl Clone for Props

Source§

fn clone(&self) -> Props

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 Props

Source§

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

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

impl Default for Props

Source§

fn default() -> Props

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Props

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<PropMap> for Props

Source§

fn from(map: PropMap) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Props

Source§

fn eq(&self, other: &Props) -> 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 Serialize for Props

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Props

Source§

impl StructuralPartialEq for Props

Auto Trait Implementations§

§

impl Freeze for Props

§

impl RefUnwindSafe for Props

§

impl Send for Props

§

impl Sync for Props

§

impl Unpin for Props

§

impl UnsafeUnpin for Props

§

impl UnwindSafe for Props

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,