Skip to main content

DocumentRegistry

Struct DocumentRegistry 

Source
pub struct DocumentRegistry { /* private fields */ }
Expand description

Registry for document type handlers.

Thread-safe, supports dynamic registration at runtime.

Implementations§

Source§

impl DocumentRegistry

Source

pub fn new() -> Self

Create an empty registry.

Source

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
Source

pub fn try_register<T: DocumentType>(&self) -> bool

Try to register a document type, returning false if already registered.

Source

pub fn is_registered(&self, type_id: u8) -> bool

Check if a type is registered.

Source

pub fn is_app_type(type_id: u8) -> bool

Check if a marker byte is an app-layer type.

Source

pub fn type_name(&self, type_id: u8) -> Option<&'static str>

Get type name for debugging.

Source

pub fn registered_types(&self) -> Vec<u8>

Get all registered type IDs.

Source

pub fn decode( &self, type_id: u8, data: &[u8], ) -> Option<Box<dyn Any + Send + Sync>>

Decode a document from bytes.

Source

pub fn merge(&self, type_id: u8, doc: &mut dyn Any, other: &dyn Any) -> bool

Merge two documents.

Source

pub fn encode(&self, type_id: u8, doc: &dyn Any) -> Vec<u8>

Encode a document to bytes.

Source

pub fn identity(&self, type_id: u8, doc: &dyn Any) -> Option<(u32, u64)>

Get document identity.

Source

pub fn to_delta_op(&self, type_id: u8, doc: &dyn Any) -> Option<AppOperation>

Convert document to delta operation.

Source

pub fn apply_delta_op( &self, type_id: u8, doc: &mut dyn Any, op: &AppOperation, ) -> bool

Apply delta operation to document.

Trait Implementations§

Source§

impl Default for DocumentRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.