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§
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Provided Methods§
Sourcefn 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 panic.
Sourcefn transact(&self) -> Transaction<'_>
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.
Sourcefn 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.
§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.
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.