Skip to main content

MapRef

Struct MapRef 

Source
pub struct MapRef<'a> { /* private fields */ }
Expand description

Read-only reference to a Map CRDT.

Maps are key-value containers where each key maps to an LWW Register. Values can be primitives or references to nested CRDTs.

Implementations§

Source§

impl<'a> MapRef<'a>

Source

pub fn id(&self) -> CrdtId

Get the CRDT ID for this map.

Source

pub fn is_root(&self) -> bool

Check if this is the root map.

Source

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

Get a value by key.

Returns the “winning” value according to LWW semantics. Use get_conflicted if you need to see concurrent conflicts.

Source

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

Get a value by key with conflict information.

If there are concurrent writes to this key, the conflicts are included.

Source

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

Check if a key exists.

Source

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

Get all keys in this map.

Source

pub fn len(&self) -> usize

Get the number of keys.

Source

pub fn is_empty(&self) -> bool

Check if the map is empty.

Source

pub fn get_map(&self, key: &str) -> Option<MapRef<'a>>

Get a nested map by key.

Source

pub fn get_text(&self, key: &str) -> Option<TextRef<'a>>

Get a nested text CRDT by key.

Source

pub fn get_set(&self, key: &str) -> Option<SetRef<'a>>

Get a nested set CRDT by key.

Source

pub fn get_register(&self, key: &str) -> Option<RegisterRef<'a>>

Get a nested register CRDT by key.

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, Value)> + 'a

Iterate over all entries.

Source

pub fn keys_owned(&self) -> Vec<String>

Collect keys as owned Strings (avoids borrow-checker friction in FFI/WASM).

Source

pub fn entries_owned(&self) -> Vec<(String, Value)>

Collect entries as owned pairs (avoids borrow-checker friction in FFI/WASM).

Auto Trait Implementations§

§

impl<'a> Freeze for MapRef<'a>

§

impl<'a> RefUnwindSafe for MapRef<'a>

§

impl<'a> Send for MapRef<'a>

§

impl<'a> Sync for MapRef<'a>

§

impl<'a> Unpin for MapRef<'a>

§

impl<'a> UnsafeUnpin for MapRef<'a>

§

impl<'a> UnwindSafe for MapRef<'a>

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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V