pub struct Mutable<'transaction, T: Table> { /* private fields */ }Expand description
Mutable access to columns of a single table row.
The whole row is retrieved and can be inspected from Rust code.
However, only rows that are not used in a #[unique]
constraint can be updated directly by dereferencing Mutable.
To update columns with a unique constraint, you have to use Mutable::unique.
Implementations§
Source§impl<'transaction, T: Table> Mutable<'transaction, T>
impl<'transaction, T: Table> Mutable<'transaction, T>
Sourcepub fn into_table_row(self) -> TableRow<T>
pub fn into_table_row(self) -> TableRow<T>
Sourcepub fn unique<O>(
&mut self,
f: impl FnOnce(&mut <T::Mutable as Deref>::Target) -> O,
) -> Result<O, T::Conflict>
pub fn unique<O>( &mut self, f: impl FnOnce(&mut <T::Mutable as Deref>::Target) -> O, ) -> Result<O, T::Conflict>
Update unique constraint columns.
When the update succeeds, this function returns Ok, when it fails it returns Err with one of three conflict types:
- 0 unique constraints => std::convert::Infallible
- 1 unique constraint => TableRow reference to the conflicting table row.
- 2+ unique constraints => crate::Conflict
If any of the changes made inside the closure conflict with an existing row, then all changes made inside the closure are reverted.
If the closure panics, then all changes made inside the closure are also reverted. Applying those changes is not possible, as conflicts can not be reported if there is a panic.