pub struct ValueMut<'a, T: WriteXDR> { /* private fields */ }Expand description
Mutable view into a Value<T>. Flushes T back to storage on drop if
it was mutated (accessed through DerefMut) since the last
flush; a guard that was only read writes nothing.
Implementations§
Source§impl<T: WriteXDR> ValueMut<'_, T>
impl<T: WriteXDR> ValueMut<'_, T>
Sourcepub fn flush(&mut self)
pub fn flush(&mut self)
Write the value back to storage now instead of waiting for drop.
A guard that has not been mutated (no DerefMut access) since the
last flush is a no-op. After a flush the guard remains usable;
mutating it again re-arms the drop-time writeback.
Sourcepub fn try_flush(&mut self) -> Result<(), LibraryExn>
pub fn try_flush(&mut self) -> Result<(), LibraryExn>
Like flush, but report failure as Err instead of
aborting (the try_ law; see the exn module
docs) — in particular, the only way to catch an error the drop-time
writeback would abort with. The Err is exactly
Value::try_set’s. On Err the guard still holds the value as
dirty: drop re-attempts the writeback and aborts if it still fails,
so a caught error cannot silently lose the write.