Skip to main content

Musefs

Struct Musefs 

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

The composed read-only filesystem: the store, the rendered tree, and the lazy synthesis cache. All methods take &self; the tree is swapped atomically on refresh, the cache is internally sharded (each shard mutex-guarded), and the data-version stamp is atomic. This makes Musefs Sync, so the FUSE layer can later share it across a worker pool.

Implementations§

Source§

impl Musefs

Source

pub fn refresh_for_test(&self) -> Result<()>

Force an unconditional rebuild of the tree from the current DB contents. Test-only: production code refreshes via poll_refresh.

Serialized against poll_refresh (and itself) through the same refreshing single-flight gate the production path uses, so overlapping rebuilds can’t publish a stale tree or race the content_version snapshot the change-diff relies on. Unlike poll_refresh, it blocks until it owns the gate rather than bailing out, so the forced rebuild always happens.

Source

pub fn poll_due(&self) -> bool

Cheap, synchronous “is a data_version poll worth dispatching?” predicate for the FUSE dispatch thread to gate fire_poll_refresh on, so a metadata-op storm doesn’t flood the worker pool with no-op poll tasks (#89). Shares the poll_debounced gate with poll_refresh_notify. Advisory only: no DB access, no data_version read, no rebuild. A stale true costs at most one task the inner gate short-circuits, and needs_rebuild is checked first so a self-heal is never debounced away.

Source

pub fn poll_refresh(&self) -> Result<bool>

See poll_refresh_notify; this is the no-callback form.

Source

pub fn poll_refresh_notify(&self, on_changed: impl FnMut(u64)) -> Result<bool>

Cheap check for external DB commits via PRAGMA data_version. On a change, rebuild the tree, prune cached resolutions to the live track set, invoke on_changed(inode) for every inode whose track’s content_version changed (its served bytes changed but its path/inode is stable), then return true. The version stamp is committed only after a successful rebuild.

Single-flighted: if a rebuild is already in progress, concurrent callers return Ok(false) immediately.

Source§

impl Musefs

Source

pub fn open(db: Db, config: MountConfig) -> Result<Musefs>

Source

pub fn lookup(&self, parent: u64, name: &str) -> Option<u64>

Source

pub fn parent(&self, inode: u64) -> Option<u64>

The parent inode of inode (root’s parent is itself). Forwards to the tree.

Source

pub fn getattr(&self, inode: u64) -> Result<Attr>

Source

pub fn readdir(&self, inode: u64) -> Result<Vec<(String, u64, bool)>>

Directory entries as (name, child_inode, is_dir).

Source

pub fn read_into( &self, inode: u64, fh: Option<Fh>, offset: u64, size: u64, out: &mut Vec<u8>, ) -> Result<()>

Source

pub fn read( &self, inode: u64, fh: Option<Fh>, offset: u64, size: u64, ) -> Result<Vec<u8>>

Allocating form of read_into.

Source

pub fn open_handle(&self, inode: u64) -> Result<Fh>

Open a file handle: resolve + validate the layout and open the backing fd once, store it, and return a handle. Subsequent reads with this handle reuse the fd (no per-read open/stat).

Source

pub fn release_handle(&self, fh: Fh)

Drop an open handle (closes its backing fd when the last reference goes).

Source

pub fn passthrough_fd(&self, fh: Fh) -> Option<PassthroughFd>

The backing fd behind fh, for kernel passthrough registration. Some only in StructureOnly mode, where the served bytes ARE the backing file; in Synthesis mode the bytes are spliced, so no single fd represents them. None also for a stale or released handle.

Source

pub fn mode(&self) -> Mode

The mount’s serving mode (how file contents are produced).

Source

pub fn entry_counts(&self) -> (u64, u64)

(files, directories) in the current virtual tree — the operator’s “is it serving the right library?” answer, surfaced on a successful mount so an empty or wrong DB is not silent (#522).

Source

pub fn telemetry(&self) -> CoreTelemetry

Snapshot the core-owned telemetry for the .musefs-metrics surface (#394). Cheap: atomic loads plus three length reads (the inodes mutex is taken briefly; a poisoned lock flags needs_rebuild via lock_or_flag, the same self-heal contract as every other VFS-state lock site).

Auto Trait Implementations§

§

impl !Freeze for Musefs

§

impl !RefUnwindSafe for Musefs

§

impl !UnwindSafe for Musefs

§

impl Send for Musefs

§

impl Sync for Musefs

§

impl Unpin for Musefs

§

impl UnsafeUnpin for Musefs

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.