Skip to main content

TransactionManager

Struct TransactionManager 

Source
pub struct TransactionManager { /* private fields */ }
Expand description

Manages copy-on-write commits and root pointer alternation.

Workflow:

  1. Filesystem operations allocate new blocks and write objects.
  2. When ready to commit, call commit() with the new superblock.
  3. TransactionManager writes the superblock to a fresh block, then updates the next root pointer slot (A or B).
  4. Old blocks can then be freed (deferred GC - not yet implemented).

Implementations§

Source§

impl TransactionManager

Source

pub fn new() -> Self

Source

pub fn from_recovered(generation: u64, last_was_b: bool) -> Self

Initialize from recovered state.

Source

pub fn generation(&self) -> u64

Current generation.

Source

pub fn commit( &mut self, store: &dyn BlockStore, crypto: &dyn CryptoEngine, codec: &PostcardCodec, allocator: &dyn SlotAllocator, superblock: &Superblock, ) -> FsResult<()>

Commit a new superblock.

  1. Allocate a block for the superblock.
  2. Write the encrypted superblock to that block.
  3. 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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V