pub struct Slot<P: Platform> { /* private fields */ }Expand description
A small object (a manifest, a superblock) committed atomically: after any crash it reads back as exactly the old or exactly the new version.
One commit is one block write plus one barrier. Commits to one slot are serialised (at most one slot write in flight).
Implementations§
Source§impl<P: Platform> Slot<P>
impl<P: Platform> Slot<P>
Sourcepub fn set_force_data_sync(&self, on: bool)
pub fn set_force_data_sync(&self, on: bool)
Makes every barrier on this region (for a slot, every commit; and
Submitter::barrier_all)
issue the OS data sync (fdatasync, FlushFileBuffers), even
on a power-safe store, where writes are durable at completion
and a barrier is otherwise free; receipts then report
data_synced. For data
whose durability should not rest on a power-safe
classification alone: a device trusted as power-safe that
still reports a volatile write cache has that cache flushed.
(On a device with no volatile cache the OS has nothing to send
it: the data is on media already. On Windows every power-safe
write is already followed by a data flush, so forcing adds
one.) It applies to every handle and generation of the region,
but is not stored: set it again after each open.
Sourcepub fn force_data_sync(&self) -> bool
pub fn force_data_sync(&self) -> bool
Whether barriers on this region always flush (see
Self::set_force_data_sync).
Source§impl<P: Platform> Slot<P>
impl<P: Platform> Slot<P>
Sourcepub fn read(&self) -> Option<Vec<u8>>
pub fn read(&self) -> Option<Vec<u8>>
The current committed object, or None if never committed.
Generation 1 of the slot pair is the provisioning header; commits start at generation 2.
Sourcepub fn commit(&self, data: &[u8]) -> Result<DurableReceipt, Error>
pub fn commit(&self, data: &[u8]) -> Result<DurableReceipt, Error>
Commits a new version of the object.
The receipt’s generation counts commits (the slot pair’s generation: 2 for the first). In format 2 a slot region also has a region generation, in its header, which a commit leaves as it is (only a recycle moves a region generation on, and slots are never recycled).
§Errors
NotWritten(TooLarge) beyond Self::capacity, Io if the store’s
queue could not be prepared (nothing was written), Poisoned, or
DurabilityUnknown (the domain is now poisoned).