Skip to main content

SyncPlugin

Struct SyncPlugin 

Source
pub struct SyncPlugin<FS: AsyncFileSystem + Clone> { /* private fields */ }
Expand description

Plugin that owns all CRDT state and handles sync commands.

Generic over FS (filesystem), but erased to Arc<dyn WorkspacePlugin> at registration. The FS: Clone bound is required for constructing Workspace<FS> and Exporter<FS>.

Implementations§

Source§

impl<FS: AsyncFileSystem + Clone + 'static> SyncPlugin<FS>

Source

pub fn new(fs: FS, storage: Arc<dyn CrdtStorage>) -> Self

Create with fresh empty CRDT state.

Source

pub fn load(fs: FS, storage: Arc<dyn CrdtStorage>) -> CoreResult<Self>

Create by loading existing CRDT state from storage.

Source

pub fn with_instances( fs: FS, workspace_crdt: Arc<WorkspaceCrdt>, body_docs: Arc<BodyDocManager>, storage: Arc<dyn CrdtStorage>, ) -> Self

Create with pre-configured CRDT instances.

Use this when consumers need Arc handles for event callbacks before plugin registration (e.g., the WASM backend).

Source

pub fn workspace_crdt(&self) -> Arc<WorkspaceCrdt>

Get the workspace CRDT handle.

Source

pub fn body_docs(&self) -> Arc<BodyDocManager>

Get the body document manager handle.

Source

pub fn sync_handler(&self) -> Arc<SyncHandler<FS>>

Get the sync handler handle.

Source

pub fn sync_manager(&self) -> Arc<RustSyncManager<FS>>

Get the sync manager handle.

Source

pub fn storage(&self) -> Arc<dyn CrdtStorage>

Get the storage handle.

Trait Implementations§

Source§

impl<FS: AsyncFileSystem + Clone + Send + Sync + 'static> Plugin for SyncPlugin<FS>

Source§

fn id(&self) -> PluginId

Unique identifier for this plugin.
Source§

fn manifest(&self) -> PluginManifest

Declarative manifest describing this plugin’s metadata and UI contributions.
Source§

fn init<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 PluginContext, ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Initialize the plugin with the given context.
Source§

fn shutdown<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Shut down the plugin, releasing any resources.
Source§

impl<FS: AsyncFileSystem + Clone + Send + Sync + 'static> WorkspacePlugin for SyncPlugin<FS>

Source§

fn on_workspace_opened<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 WorkspaceOpenedEvent, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called when a workspace is opened.
Source§

fn handle_command<'life0, 'life1, 'async_trait>( &'life0 self, cmd: &'life1 str, params: JsonValue, ) -> Pin<Box<dyn Future<Output = Option<Result<JsonValue, PluginError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle a plugin-specific command. Read more
Source§

fn notify_workspace_modified<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called after a workspace-modifying operation completes. Read more
Source§

fn on_body_doc_renamed<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, old_path: &'life1 str, new_path: &'life2 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called when a body document needs to be renamed (file was moved/renamed). Read more
Source§

fn on_body_doc_deleted<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called when a body document should be deleted. Read more
Source§

fn track_file_for_sync<'life0, 'life1, 'async_trait>( &'life0 self, canonical_path: &'life1 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called after a file operation to track CRDT metadata for echo detection. Read more
Source§

fn get_canonical_path(&self, storage_path: &str) -> Option<String>

Resolve a canonical path from a storage path. Read more
Source§

fn track_content_for_sync(&self, canonical_path: &str, content: &str)

Track body content for echo detection. Read more
Source§

fn get_file_title(&self, canonical_path: &str) -> Option<String>

Get the title for a file from CRDT metadata. Read more
Source§

fn on_workspace_closed<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 WorkspaceClosedEvent, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Called when a workspace is closed.
Source§

fn on_workspace_changed<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 WorkspaceChangedEvent, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Called when workspace metadata changes.
Source§

fn on_workspace_committed<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 WorkspaceCommittedEvent, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Called when a workspace is committed (e.g., git commit or sync checkpoint).
Source§

fn get_config<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<Value>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sync + 'async_trait,

Get this plugin’s configuration (if any).
Source§

fn set_config<'life0, 'async_trait>( &'life0 self, _config: Value, ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sync + 'async_trait,

Update this plugin’s configuration.

Auto Trait Implementations§

§

impl<FS> !Freeze for SyncPlugin<FS>

§

impl<FS> !RefUnwindSafe for SyncPlugin<FS>

§

impl<FS> Send for SyncPlugin<FS>

§

impl<FS> Sync for SyncPlugin<FS>

§

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

§

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

§

impl<FS> !UnwindSafe for SyncPlugin<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> 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.