Skip to main content

PropMap

Struct PropMap 

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

Ordered map of prop key-value pairs.

Uses a Vec for storage since widget props are typically small (5-15 entries). Linear scan is faster than hashing for this size.

§Wire serialisation key order

Props are serialised to JSON via into_json_map which collects into a serde_json::Map. The workspace compiles serde_json without the preserve_order feature, so Map is an alphabetical-key BTreeMap equivalent. That keeps direct JSON serialisation stable for protocol-facing code and prop regression tests in this crate. Enabling preserve_order would make JSON serialisation insertion-ordered and change the emitted wire shape.

Implementations§

Source§

impl PropMap

Source

pub fn new() -> Self

Construct a new value.

Source

pub fn with_capacity(cap: usize) -> Self

Return a new value with the capacity set.

Source

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

Get a prop value by key.

Source

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

Get a mutable reference to a prop value by key.

Source

pub fn insert(&mut self, key: impl Into<String>, value: impl Into<PropValue>)

Insert or replace a prop value.

Source

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

Remove a prop by key, returning the old value if present.

Source

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

Set or construct contains_key.

Source

pub fn is_empty(&self) -> bool

Returns true when the empty condition holds.

Source

pub fn len(&self) -> usize

Set or construct len.

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, &PropValue)>

Iterate over (key, value) pairs.

Source

pub fn keys(&self) -> impl Iterator<Item = &str>

Iterate over keys.

Source

pub fn from_json_map(map: Map<String, Value>) -> Self

Convert from a serde_json Map.

Source

pub fn into_json_map(self) -> Map<String, Value>

Convert to a serde_json Map.

Trait Implementations§

Source§

impl Clone for PropMap

Source§

fn clone(&self) -> PropMap

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 PropMap

Source§

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

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

impl Default for PropMap

Source§

fn default() -> PropMap

Returns the “default value” for a type. 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 PropMap

Source§

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

Wire-canonical equality: null-valued entries are equivalent to absent entries. The wire protocol encodes key removal by sending null, so {} and {"a": null} are indistinguishable downstream and must compare equal here. Without this, tree_diff + apply_patch could not round-trip trees whose only difference is a null-valued prop, because there is no protocol op that adds an explicit null-valued key.

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 Eq for PropMap

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.