pub struct SyncDocument { /* private fields */ }concurrency only.Expand description
Thread-safe wrapper for EditorDocument
Provides synchronized access to an EditorDocument, allowing multiple threads to safely read and modify the document. Uses RwLock for efficient concurrent reads.
Note: Due to Bump allocator using Cell types, EditorDocument is not Sync. SyncDocument provides thread-safe access through RwLock synchronization. The RwLock ensures that only one thread can write at a time, and the interior mutability of Bump is safe within a single thread.
Implementations§
Source§impl SyncDocument
impl SyncDocument
Sourcepub fn new(document: EditorDocument) -> Self
pub fn new(document: EditorDocument) -> Self
Create a new thread-safe document
Sourcepub fn from_document(document: EditorDocument) -> Self
pub fn from_document(document: EditorDocument) -> Self
Create from an existing document
Sourcepub fn read(&self) -> Result<RwLockReadGuard<'_, EditorDocument>>
pub fn read(&self) -> Result<RwLockReadGuard<'_, EditorDocument>>
Get a read-only reference to the document
Sourcepub fn write(&self) -> Result<RwLockWriteGuard<'_, EditorDocument>>
pub fn write(&self) -> Result<RwLockWriteGuard<'_, EditorDocument>>
Get a mutable reference to the document
Sourcepub fn execute_command<C: EditorCommand>(
&self,
command: C,
) -> Result<CommandResult>
pub fn execute_command<C: EditorCommand>( &self, command: C, ) -> Result<CommandResult>
Execute a command atomically
Sourcepub fn try_read(&self) -> Option<RwLockReadGuard<'_, EditorDocument>>
pub fn try_read(&self) -> Option<RwLockReadGuard<'_, EditorDocument>>
Try to get a read-only reference without blocking
Sourcepub fn try_write(&self) -> Option<RwLockWriteGuard<'_, EditorDocument>>
pub fn try_write(&self) -> Option<RwLockWriteGuard<'_, EditorDocument>>
Try to get a mutable reference without blocking
Sourcepub fn with_read<F, R>(&self, f: F) -> Result<R>where
F: FnOnce(&EditorDocument) -> R,
pub fn with_read<F, R>(&self, f: F) -> Result<R>where
F: FnOnce(&EditorDocument) -> R,
Perform an operation with read access
Sourcepub fn with_write<F, R>(&self, f: F) -> Result<R>
pub fn with_write<F, R>(&self, f: F) -> Result<R>
Perform an operation with write access
Sourcepub fn clone_document(&self) -> Result<EditorDocument>
pub fn clone_document(&self) -> Result<EditorDocument>
Clone the underlying document
Sourcepub fn validate_comprehensive(&self) -> Result<Vec<ValidationIssue>>
pub fn validate_comprehensive(&self) -> Result<Vec<ValidationIssue>>
Validate comprehensive (requires mutable access for LazyValidator)
Trait Implementations§
Source§impl Clone for SyncDocument
impl Clone for SyncDocument
Source§fn clone(&self) -> SyncDocument
fn clone(&self) -> SyncDocument
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more