Struct loro_internal::handler::TextHandler
source · pub struct TextHandler { /* private fields */ }
Expand description
Flatten attributes that allow overlap
Implementations§
source§impl TextHandler
impl TextHandler
sourcepub fn new_detached() -> Self
pub fn new_detached() -> Self
Create a new container that is detached from the document.
The edits on a detached container will not be persisted. To attach the container to the document, please insert it into an attached container.
pub fn get_richtext_value(&self) -> LoroValue
pub fn is_empty(&self) -> bool
pub fn len_utf8(&self) -> usize
pub fn len_utf16(&self) -> usize
pub fn len_unicode(&self) -> usize
sourcepub fn len_event(&self) -> usize
pub fn len_event(&self) -> usize
if wasm
feature is enabled, it is a UTF-16 length
otherwise, it is a Unicode length
pub fn diagnose(&self)
sourcepub fn insert(&self, pos: usize, s: &str) -> LoroResult<()>
pub fn insert(&self, pos: usize, s: &str) -> LoroResult<()>
pos
is a Event Index:
- if feature=“wasm”, pos is a UTF-16 index
- if feature!=“wasm”, pos is a Unicode index
This method requires auto_commit to be enabled.
sourcepub fn insert_with_txn(
&self,
txn: &mut Transaction,
pos: usize,
s: &str
) -> LoroResult<()>
pub fn insert_with_txn( &self, txn: &mut Transaction, pos: usize, s: &str ) -> LoroResult<()>
pos
is a Event Index:
- if feature=“wasm”, pos is a UTF-16 index
- if feature!=“wasm”, pos is a Unicode index
sourcepub fn delete(&self, pos: usize, len: usize) -> LoroResult<()>
pub fn delete(&self, pos: usize, len: usize) -> LoroResult<()>
pos
is a Event Index:
- if feature=“wasm”, pos is a UTF-16 index
- if feature!=“wasm”, pos is a Unicode index
This method requires auto_commit to be enabled.
sourcepub fn delete_with_txn(
&self,
txn: &mut Transaction,
pos: usize,
len: usize
) -> LoroResult<()>
pub fn delete_with_txn( &self, txn: &mut Transaction, pos: usize, len: usize ) -> LoroResult<()>
pos
is a Event Index:
- if feature=“wasm”, pos is a UTF-16 index
- if feature!=“wasm”, pos is a Unicode index
sourcepub fn mark(
&self,
start: usize,
end: usize,
key: impl Into<InternalString>,
value: LoroValue
) -> LoroResult<()>
pub fn mark( &self, start: usize, end: usize, key: impl Into<InternalString>, value: LoroValue ) -> LoroResult<()>
start
and end
are [Event Index]s:
- if feature=“wasm”, pos is a UTF-16 index
- if feature!=“wasm”, pos is a Unicode index
This method requires auto_commit to be enabled.
sourcepub fn unmark(
&self,
start: usize,
end: usize,
key: impl Into<InternalString>
) -> LoroResult<()>
pub fn unmark( &self, start: usize, end: usize, key: impl Into<InternalString> ) -> LoroResult<()>
start
and end
are [Event Index]s:
- if feature=“wasm”, pos is a UTF-16 index
- if feature!=“wasm”, pos is a Unicode index
This method requires auto_commit to be enabled.
sourcepub fn mark_with_txn(
&self,
txn: &mut Transaction,
start: usize,
end: usize,
key: impl Into<InternalString>,
value: LoroValue,
is_delete: bool
) -> LoroResult<()>
pub fn mark_with_txn( &self, txn: &mut Transaction, start: usize, end: usize, key: impl Into<InternalString>, value: LoroValue, is_delete: bool ) -> LoroResult<()>
start
and end
are [Event Index]s:
- if feature=“wasm”, pos is a UTF-16 index
- if feature!=“wasm”, pos is a Unicode index
pub fn check(&self)
pub fn apply_delta(&self, delta: &[TextDelta]) -> LoroResult<()>
pub fn apply_delta_with_txn( &self, txn: &mut Transaction, delta: &[TextDelta] ) -> LoroResult<()>
pub fn to_string(&self) -> String
Trait Implementations§
source§impl Clone for TextHandler
impl Clone for TextHandler
source§fn clone(&self) -> TextHandler
fn clone(&self) -> TextHandler
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TextHandler
impl Debug for TextHandler
source§impl HandlerTrait for TextHandler
impl HandlerTrait for TextHandler
fn to_handler(&self) -> Handler
source§fn attach(
&self,
txn: &mut Transaction,
parent: &BasicHandler,
self_id: ContainerID
) -> LoroResult<Self>
fn attach( &self, txn: &mut Transaction, parent: &BasicHandler, self_id: ContainerID ) -> LoroResult<Self>
This method returns an attached handler.
fn attached_handler(&self) -> Option<&BasicHandler>
fn get_value(&self) -> LoroValue
fn get_deep_value(&self) -> LoroValue
fn is_attached(&self) -> bool
fn kind(&self) -> ContainerType
source§fn get_attached(&self) -> Option<Self>
fn get_attached(&self) -> Option<Self>
If a detached container is attached, this method will return its corresponding attached handler.
fn from_handler(h: Handler) -> Option<Self>
fn parent(&self) -> Option<Handler>
fn idx(&self) -> ContainerIdx
fn id(&self) -> ContainerID
fn with_state<R>( &self, f: impl FnOnce(&mut State) -> LoroResult<R> ) -> LoroResult<R>
Auto Trait Implementations§
impl Freeze for TextHandler
impl RefUnwindSafe for TextHandler
impl Send for TextHandler
impl Sync for TextHandler
impl Unpin for TextHandler
impl UnwindSafe for TextHandler
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