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§
Sourcetype Handler: HandlerTrait
type Handler: HandlerTrait
The handler of the container.
Required Methods§
Sourcefn id(&self) -> ContainerID
fn id(&self) -> ContainerID
Get the ID of the container.
Sourcefn to_container(&self) -> Container
fn to_container(&self) -> Container
Convert the container to a Container.
Sourcefn to_handler(&self) -> Self::Handler
fn to_handler(&self) -> Self::Handler
Convert the container to a handler.
Sourcefn from_handler(handler: Self::Handler) -> Self
fn from_handler(handler: Self::Handler) -> Self
Convert the handler to a container.
Sourcefn try_from_container(container: Container) -> Option<Self>where
Self: Sized,
fn try_from_container(container: Container) -> Option<Self>where
Self: Sized,
Try to convert the container to the handler.
Sourcefn is_attached(&self) -> bool
fn is_attached(&self) -> bool
Whether the container is attached to a document.
Sourcefn get_attached(&self) -> Option<Self>where
Self: Sized,
fn get_attached(&self) -> Option<Self>where
Self: Sized,
If a detached container is attached, this method will return its corresponding attached handler.
Sourcefn is_deleted(&self) -> bool
fn is_deleted(&self) -> bool
Whether the container is deleted.
Provided Methods§
Sourcefn subscribe(&self, callback: Subscriber) -> Option<Subscription>
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.