Skip to main content

Transaction

Struct Transaction 

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

A transaction for batched mutations.

Transactions capture the agent ID so you don’t need to pass it to each mutation. They also provide a clean solution to Rust’s borrow checker issues when working with nested CRDTs.

Transactions are created by Document::transact() and cannot be created directly.

Implementations§

Source§

impl<'a> Transaction<'a>

Source

pub fn agent(&self) -> AgentId

Get the agent ID for this transaction.

Source

pub fn root(&mut self) -> MapMut<'_>

Get a mutable reference to the root map.

Source

pub fn get_map_mut(&mut self, path: &[&str]) -> Option<MapMut<'_>>

Get a mutable reference to a map at the given path. Returns None if path doesn’t exist.

Source

pub fn get_text_mut(&mut self, path: &[&str]) -> Option<TextMut<'_>>

Get a mutable reference to a text CRDT at the given path. Returns None if path doesn’t exist or isn’t a Text.

Source

pub fn get_set_mut(&mut self, path: &[&str]) -> Option<SetMut<'_>>

Get a mutable reference to a set CRDT at the given path. Returns None if path doesn’t exist or isn’t a Set.

Source

pub fn map_by_id(&mut self, id: CrdtId) -> MapMut<'_>

Get a mutable reference to a map by its CRDT ID.

Source

pub fn text_by_id(&mut self, id: CrdtId) -> Option<TextMut<'_>>

Get a mutable reference to a text CRDT by its ID.

Source

pub fn set_by_id(&mut self, id: CrdtId) -> Option<SetMut<'_>>

Get a mutable reference to a set CRDT by its ID.

Auto Trait Implementations§

§

impl<'a> Freeze for Transaction<'a>

§

impl<'a> RefUnwindSafe for Transaction<'a>

§

impl<'a> Send for Transaction<'a>

§

impl<'a> Sync for Transaction<'a>

§

impl<'a> Unpin for Transaction<'a>

§

impl<'a> UnsafeUnpin for Transaction<'a>

§

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