Trait Transact
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>;
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§
fn try_transact(&self) -> Result<Transaction<'_>, TransactionAcqError>
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.
fn try_transact_mut(&self) -> Result<TransactionMut<'_>, TransactionAcqError>
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.
fn try_transact_mut_with<T>(
&self,
origin: T,
) -> Result<TransactionMut<'_>, TransactionAcqError>
fn try_transact_mut_with<T>( &self, origin: T, ) -> Result<TransactionMut<'_>, TransactionAcqError>
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.
fn transact_mut_with<T>(&self, origin: T) -> TransactionMut<'_>
fn transact_mut_with<T>(&self, origin: T) -> TransactionMut<'_>
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
block the thread until exclusive access can be acquired, unless building for wasm
which panics. If blocking is undesirable, use try_transact_mut_with(origin).unwrap() instead`.
fn transact(&self) -> Transaction<'_>
fn transact(&self) -> Transaction<'_>
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 block the thread until exclusive access can be acquired, unless building for wasm
which panics. If blocking is undesirable, use try_transact(origin).unwrap() instead`.
fn transact_mut(&self) -> TransactionMut<'_>
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.
§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 block
the thread until exclusive access can be acquired, unless building for wasm
which panics. If blocking is undesirable, use try_transact_mut(origin).unwrap() instead`.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.