Skip to main content

MapMut

Struct MapMut 

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

Mutable reference to a Map CRDT.

Obtained through Transaction::root() or Transaction::get_map_mut().

Implementations§

Source§

impl<'a> MapMut<'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 set(&mut self, key: &str, value: impl Into<PrimitiveValue>)

Set a key to a primitive value.

Accepts any type that implements Into<PrimitiveValue>: bool, i64, i32, String, &str, or () for nil.

To create nested CRDTs, use create_map(), create_text(), create_set(), or create_register() instead.

Source

pub fn set_nil(&mut self, key: &str)

Set a key to nil (tombstone).

In CRDT semantics, this creates a tombstone - the key still exists but has a nil value. Use get() to check if a value is nil, or use get_conflicted() to see if there are concurrent non-nil values.

Note: contains_key() will still return true after this operation.

Source

pub fn create_map(&mut self, key: &str) -> CrdtId

Create a nested Map at the given key.

Returns the CRDT ID of the new map, which can be used with Transaction::map_by_id() to get a mutable reference.

Source

pub fn create_text(&mut self, key: &str) -> CrdtId

Create a nested Text CRDT at the given key.

Returns the CRDT ID of the new text.

Source

pub fn create_set(&mut self, key: &str) -> CrdtId

Create a nested Set CRDT at the given key.

Returns the CRDT ID of the new set.

Source

pub fn create_register(&mut self, key: &str) -> CrdtId

Create a nested Register CRDT at the given key.

Returns the CRDT ID of the new register.

Auto Trait Implementations§

§

impl<'a> Freeze for MapMut<'a>

§

impl<'a> RefUnwindSafe for MapMut<'a>

§

impl<'a> Send for MapMut<'a>

§

impl<'a> Sync for MapMut<'a>

§

impl<'a> Unpin for MapMut<'a>

§

impl<'a> UnsafeUnpin for MapMut<'a>

§

impl<'a> !UnwindSafe for MapMut<'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