pub struct DocumentRegistry { /* private fields */ }Expand description
Registry for document type handlers.
Thread-safe, supports dynamic registration at runtime.
Implementations§
Source§impl DocumentRegistry
impl DocumentRegistry
Sourcepub fn register<T: DocumentType>(&self)
pub fn register<T: DocumentType>(&self)
Register a document type handler.
§Panics
Panics if:
- TYPE_ID is outside 0xC0-0xCF range
- TYPE_ID is already registered
Sourcepub fn try_register<T: DocumentType>(&self) -> bool
pub fn try_register<T: DocumentType>(&self) -> bool
Try to register a document type, returning false if already registered.
Sourcepub fn is_registered(&self, type_id: u8) -> bool
pub fn is_registered(&self, type_id: u8) -> bool
Check if a type is registered.
Sourcepub fn is_app_type(type_id: u8) -> bool
pub fn is_app_type(type_id: u8) -> bool
Check if a marker byte is an app-layer type.
Sourcepub fn registered_types(&self) -> Vec<u8> ⓘ
pub fn registered_types(&self) -> Vec<u8> ⓘ
Get all registered type IDs.
Sourcepub fn decode(
&self,
type_id: u8,
data: &[u8],
) -> Option<Box<dyn Any + Send + Sync>>
pub fn decode( &self, type_id: u8, data: &[u8], ) -> Option<Box<dyn Any + Send + Sync>>
Decode a document from bytes.
Sourcepub fn merge(&self, type_id: u8, doc: &mut dyn Any, other: &dyn Any) -> bool
pub fn merge(&self, type_id: u8, doc: &mut dyn Any, other: &dyn Any) -> bool
Merge two documents.
Sourcepub fn identity(&self, type_id: u8, doc: &dyn Any) -> Option<(u32, u64)>
pub fn identity(&self, type_id: u8, doc: &dyn Any) -> Option<(u32, u64)>
Get document identity.
Sourcepub fn to_delta_op(&self, type_id: u8, doc: &dyn Any) -> Option<AppOperation>
pub fn to_delta_op(&self, type_id: u8, doc: &dyn Any) -> Option<AppOperation>
Convert document to delta operation.
Sourcepub fn apply_delta_op(
&self,
type_id: u8,
doc: &mut dyn Any,
op: &AppOperation,
) -> bool
pub fn apply_delta_op( &self, type_id: u8, doc: &mut dyn Any, op: &AppOperation, ) -> bool
Apply delta operation to document.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DocumentRegistry
impl RefUnwindSafe for DocumentRegistry
impl Send for DocumentRegistry
impl Sync for DocumentRegistry
impl Unpin for DocumentRegistry
impl UnsafeUnpin for DocumentRegistry
impl UnwindSafe for DocumentRegistry
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