Skip to main content

DecoratedFs

Struct DecoratedFs 

Source
pub struct DecoratedFs<FS: AsyncFileSystem> {
    pub fs: EventEmittingFs<CrdtFs<FS>>,
    pub workspace_crdt: Arc<WorkspaceCrdt>,
    pub body_doc_manager: Arc<BodyDocManager>,
    pub event_registry: Arc<CallbackRegistry>,
    pub storage: Arc<dyn CrdtStorage>,
}
Expand description

A fully decorated filesystem with runtime control handles.

This struct contains:

  • The decorated filesystem stack
  • Handles for runtime control (enable/disable CRDT, events)
  • Access to CRDTs for observer registration

§Example

use diaryx_core::fs::{DecoratedFsBuilder, InMemoryFileSystem, SyncToAsyncFs};
use diaryx_core::types::MemoryStorage;
use std::sync::Arc;

let base_fs = SyncToAsyncFs::new(InMemoryFileSystem::new());
let storage = Arc::new(MemoryStorage::new());

let decorated = DecoratedFsBuilder::new(base_fs)
    .with_crdt(storage)
    .build();

// Use the filesystem
decorated.fs.write_file(Path::new("test.md"), "content").await?;

// Access runtime controls
decorated.set_crdt_enabled(false);
decorated.set_events_enabled(false);

// Subscribe to events
decorated.on_event(Arc::new(|event| println!("{:?}", event)));

Fields§

§fs: EventEmittingFs<CrdtFs<FS>>

The fully decorated filesystem stack. Stack: EventEmittingFs<CrdtFs>

§workspace_crdt: Arc<WorkspaceCrdt>

The workspace CRDT for file metadata.

§body_doc_manager: Arc<BodyDocManager>

The body document manager for file content.

§event_registry: Arc<CallbackRegistry>

The event callback registry.

§storage: Arc<dyn CrdtStorage>

The CRDT storage backend.

Implementations§

Source§

impl<FS: AsyncFileSystem> DecoratedFs<FS>

Source

pub fn set_crdt_enabled(&self, enabled: bool)

Enable or disable CRDT updates.

Source

pub fn is_crdt_enabled(&self) -> bool

Check if CRDT updates are enabled.

Source

pub fn set_events_enabled(&self, enabled: bool)

Enable or disable event emission.

Source

pub fn is_events_enabled(&self) -> bool

Check if event emission is enabled.

Source

pub fn on_event(&self, callback: EventCallback) -> SubscriptionId

Subscribe to filesystem events.

Returns a subscription ID that can be used to unsubscribe.

Source

pub fn off_event(&self, id: SubscriptionId) -> bool

Unsubscribe from filesystem events.

Source

pub fn base_fs(&self) -> &FS

Get a reference to the inner base filesystem.

Source

pub fn crdt_fs(&self) -> &CrdtFs<FS>

Get a reference to the CrdtFs layer.

Source

pub fn event_fs(&self) -> &EventEmittingFs<CrdtFs<FS>>

Get a reference to the EventEmittingFs layer.

Source

pub fn set_workspace_root(&self, root: PathBuf)

Set the workspace root on the CrdtFs layer for path normalization.

Source

pub fn workspace_root_handle(&self) -> Arc<RwLock<Option<PathBuf>>>

Get a shared handle to the CrdtFs workspace root.

Trait Implementations§

Source§

impl<FS: AsyncFileSystem + Clone> Clone for DecoratedFs<FS>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<FS: AsyncFileSystem> Debug for DecoratedFs<FS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<FS> !Freeze for DecoratedFs<FS>

§

impl<FS> !RefUnwindSafe for DecoratedFs<FS>

§

impl<FS> Send for DecoratedFs<FS>

§

impl<FS> Sync for DecoratedFs<FS>

§

impl<FS> Unpin for DecoratedFs<FS>
where FS: Unpin,

§

impl<FS> UnsafeUnpin for DecoratedFs<FS>
where FS: UnsafeUnpin,

§

impl<FS> !UnwindSafe for DecoratedFs<FS>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.