pub struct TransactionManager { /* private fields */ }Expand description
Manages copy-on-write commits and root pointer alternation.
Workflow:
- Filesystem operations allocate new blocks and write objects.
- When ready to commit, call
commit()with the new superblock. - TransactionManager writes the superblock to a fresh block, then updates the next root pointer slot (A or B).
- Old blocks can then be freed (deferred GC - not yet implemented).
Implementations§
Source§impl TransactionManager
impl TransactionManager
pub fn new() -> Self
Sourcepub fn from_recovered(generation: u64, last_was_b: bool) -> Self
pub fn from_recovered(generation: u64, last_was_b: bool) -> Self
Initialize from recovered state.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Current generation.
Sourcepub fn commit(
&mut self,
store: &dyn BlockStore,
crypto: &dyn CryptoEngine,
codec: &PostcardCodec,
allocator: &dyn SlotAllocator,
superblock: &Superblock,
) -> FsResult<()>
pub fn commit( &mut self, store: &dyn BlockStore, crypto: &dyn CryptoEngine, codec: &PostcardCodec, allocator: &dyn SlotAllocator, superblock: &Superblock, ) -> FsResult<()>
Commit a new superblock.
- Allocate a block for the superblock.
- Write the encrypted superblock to that block.
- Write the root pointer to the next slot (A or B), unencrypted (root pointers are integrity-checked via BLAKE3 but not encrypted so we can read them without the key to find the superblock).
Note: root pointers are written unencrypted but with a checksum. The superblock itself is encrypted.
Sourcepub fn read_root_pointer(
store: &dyn BlockStore,
codec: &PostcardCodec,
slot: u64,
) -> FsResult<Option<RootPointer>>
pub fn read_root_pointer( store: &dyn BlockStore, codec: &PostcardCodec, slot: u64, ) -> FsResult<Option<RootPointer>>
Try to read a root pointer from a slot. Returns None if the slot is empty/invalid.
Sourcepub fn recover_latest(
store: &dyn BlockStore,
codec: &PostcardCodec,
) -> FsResult<Option<(RootPointer, bool)>>
pub fn recover_latest( store: &dyn BlockStore, codec: &PostcardCodec, ) -> FsResult<Option<(RootPointer, bool)>>
Recover the latest valid root pointer by reading both slots. Returns (RootPointer, was_slot_b).
Auto Trait Implementations§
impl Freeze for TransactionManager
impl RefUnwindSafe for TransactionManager
impl Send for TransactionManager
impl Sync for TransactionManager
impl Unpin for TransactionManager
impl UnsafeUnpin for TransactionManager
impl UnwindSafe for TransactionManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more