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>
impl<FS: AsyncFileSystem> DecoratedFs<FS>
Sourcepub fn set_crdt_enabled(&self, enabled: bool)
pub fn set_crdt_enabled(&self, enabled: bool)
Enable or disable CRDT updates.
Sourcepub fn is_crdt_enabled(&self) -> bool
pub fn is_crdt_enabled(&self) -> bool
Check if CRDT updates are enabled.
Sourcepub fn set_events_enabled(&self, enabled: bool)
pub fn set_events_enabled(&self, enabled: bool)
Enable or disable event emission.
Sourcepub fn is_events_enabled(&self) -> bool
pub fn is_events_enabled(&self) -> bool
Check if event emission is enabled.
Sourcepub fn on_event(&self, callback: EventCallback) -> SubscriptionId
pub fn on_event(&self, callback: EventCallback) -> SubscriptionId
Subscribe to filesystem events.
Returns a subscription ID that can be used to unsubscribe.
Sourcepub fn off_event(&self, id: SubscriptionId) -> bool
pub fn off_event(&self, id: SubscriptionId) -> bool
Unsubscribe from filesystem events.
Sourcepub fn event_fs(&self) -> &EventEmittingFs<CrdtFs<FS>>
pub fn event_fs(&self) -> &EventEmittingFs<CrdtFs<FS>>
Get a reference to the EventEmittingFs layer.
Sourcepub fn set_workspace_root(&self, root: PathBuf)
pub fn set_workspace_root(&self, root: PathBuf)
Set the workspace root on the CrdtFs layer for path normalization.
Trait Implementations§
Source§impl<FS: AsyncFileSystem + Clone> Clone for DecoratedFs<FS>
impl<FS: AsyncFileSystem + Clone> Clone for DecoratedFs<FS>
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> 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