ContainerTrait

Trait ContainerTrait 

Source
pub trait ContainerTrait: SealedTrait {
    type Handler: HandlerTrait;

    // Required methods
    fn id(&self) -> ContainerID;
    fn to_container(&self) -> Container;
    fn to_handler(&self) -> Self::Handler;
    fn from_handler(handler: Self::Handler) -> Self;
    fn try_from_container(container: Container) -> Option<Self>
       where Self: Sized;
    fn is_attached(&self) -> bool;
    fn get_attached(&self) -> Option<Self>
       where Self: Sized;
    fn is_deleted(&self) -> bool;
    fn doc(&self) -> Option<LoroDoc>;

    // Provided method
    fn subscribe(&self, callback: Subscriber) -> Option<Subscription> { ... }
}
Expand description

The common trait for all the containers. It’s used internally, you can’t implement it directly.

Required Associated Types§

Source

type Handler: HandlerTrait

The handler of the container.

Required Methods§

Source

fn id(&self) -> ContainerID

Get the ID of the container.

Source

fn to_container(&self) -> Container

Convert the container to a Container.

Source

fn to_handler(&self) -> Self::Handler

Convert the container to a handler.

Source

fn from_handler(handler: Self::Handler) -> Self

Convert the handler to a container.

Source

fn try_from_container(container: Container) -> Option<Self>
where Self: Sized,

Try to convert the container to the handler.

Source

fn is_attached(&self) -> bool

Whether the container is attached to a document.

Source

fn get_attached(&self) -> Option<Self>
where Self: Sized,

If a detached container is attached, this method will return its corresponding attached handler.

Source

fn is_deleted(&self) -> bool

Whether the container is deleted.

Source

fn doc(&self) -> Option<LoroDoc>

Get the doc of the container.

Provided Methods§

Source

fn subscribe(&self, callback: Subscriber) -> Option<Subscription>

Subscribe to the container.

If the Container is detached, this method will return None.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§