Trait yrs::doc::Transact

source ·
pub trait Transact {
    // Required methods
    fn try_transact(&self) -> Result<Transaction<'_>, TransactionAcqError>;
    fn try_transact_mut(
        &self
    ) -> Result<TransactionMut<'_>, TransactionAcqError>;
    fn try_transact_mut_with<T>(
        &self,
        origin: T
    ) -> Result<TransactionMut<'_>, TransactionAcqError>
       where T: Into<Origin>;

    // Provided methods
    fn transact_mut_with<T>(&self, origin: T) -> TransactionMut<'_>
       where T: Into<Origin> { ... }
    fn transact(&self) -> Transaction<'_> { ... }
    fn transact_mut(&self) -> TransactionMut<'_> { ... }
}
Expand description

Trait implemented by Doc and shared types, used for carrying over the responsibilities of creating new transactions, used as a unit of work in Yrs.

Required Methods§

source

fn try_transact(&self) -> Result<Transaction<'_>, TransactionAcqError>

Creates and returns a lightweight read-only transaction.

§Errors

While it’s possible to have multiple read-only transactions active at the same time, this method will return a TransactionAcqError::SharedAcqFailed error whenever called while a read-write transaction (see: Self::try_transact_mut) is active at the same time.

source

fn try_transact_mut(&self) -> Result<TransactionMut<'_>, TransactionAcqError>

Creates and returns a read-write capable transaction. This transaction can be used to mutate the contents of underlying document store and upon dropping or committing it may subscription callbacks.

§Errors

Only one read-write transaction can be active at the same time. If any other transaction - be it a read-write or read-only one - is active at the same time, this method will return a TransactionAcqError::ExclusiveAcqFailed error.

source

fn try_transact_mut_with<T>( &self, origin: T ) -> Result<TransactionMut<'_>, TransactionAcqError>
where T: Into<Origin>,

Creates and returns a read-write capable transaction with an origin classifier attached. This transaction can be used to mutate the contents of underlying document store and upon dropping or committing it may subscription callbacks.

An origin may be used to identify context of operations made (example updates performed locally vs. incoming from remote replicas) and it’s used i.e. by UndoManager.

§Errors

Only one read-write transaction can be active at the same time. If any other transaction - be it a read-write or read-only one - is active at the same time, this method will return a TransactionAcqError::ExclusiveAcqFailed error.

Provided Methods§

source

fn transact_mut_with<T>(&self, origin: T) -> TransactionMut<'_>
where T: Into<Origin>,

Creates and returns a read-write capable transaction with an origin classifier attached. This transaction can be used to mutate the contents of underlying document store and upon dropping or committing it may subscription callbacks.

An origin may be used to identify context of operations made (example updates performed locally vs. incoming from remote replicas) and it’s used i.e. by UndoManager.

§Errors

Only one read-write transaction can be active at the same time. If any other transaction - be it a read-write or read-only one - is active at the same time, this method will panic.

source

fn transact(&self) -> Transaction<'_>

Creates and returns a lightweight read-only transaction.

§Panics

While it’s possible to have multiple read-only transactions active at the same time, this method will panic whenever called while a read-write transaction (see: Self::transact_mut) is active at the same time.

source

fn transact_mut(&self) -> TransactionMut<'_>

Creates and returns a read-write capable transaction. This transaction can be used to mutate the contents of underlying document store and upon dropping or committing it may subscription callbacks.

§Panics

Only one read-write transaction can be active at the same time. If any other transaction - be it a read-write or read-only one - is active at the same time, this method will panic.

Object Safety§

This trait is not object safe.

Implementors§