pub struct LoroMovableList { /* private fields */ }Implementations§
Source§impl LoroMovableList
impl LoroMovableList
pub fn new() -> Self
Sourcepub fn id(&self) -> ContainerID
pub fn id(&self) -> ContainerID
Get the container id.
Sourcepub fn is_attached(&self) -> bool
pub fn is_attached(&self) -> bool
Whether the container is attached to a 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.
Sourcepub fn get_attached(&self) -> Option<Arc<LoroMovableList>>
pub fn get_attached(&self) -> Option<Arc<LoroMovableList>>
If a detached container is attached, this method will return its corresponding attached handler.
Sourcepub fn insert(&self, pos: u32, v: Arc<dyn LoroValueLike>) -> LoroResult<()>
pub fn insert(&self, pos: u32, v: Arc<dyn LoroValueLike>) -> LoroResult<()>
Insert a value at the given position.
Sourcepub fn delete(&self, pos: u32, len: u32) -> LoroResult<()>
pub fn delete(&self, pos: u32, len: u32) -> LoroResult<()>
Delete values at the given position.
Sourcepub fn get(&self, index: u32) -> Option<Arc<dyn ValueOrContainer>>
pub fn get(&self, index: u32) -> Option<Arc<dyn ValueOrContainer>>
Get the value at the given position.
Sourcepub fn get_value(&self) -> LoroValue
pub fn get_value(&self) -> LoroValue
Get the shallow value of the list.
It will not convert the state of sub-containers, but represent them as LoroValue::Container.
Sourcepub fn get_deep_value(&self) -> LoroValue
pub fn get_deep_value(&self) -> LoroValue
Get the deep value of the list.
It will convert the state of sub-containers into a nested JSON value.
Sourcepub fn pop(&self) -> LoroResult<Option<Arc<dyn ValueOrContainer>>>
pub fn pop(&self) -> LoroResult<Option<Arc<dyn ValueOrContainer>>>
Pop the last element of the list.
pub fn push(&self, v: Arc<dyn LoroValueLike>) -> LoroResult<()>
pub fn insert_list_container( &self, pos: u32, child: Arc<LoroList>, ) -> LoroResult<Arc<LoroList>>
pub fn insert_map_container( &self, pos: u32, child: Arc<LoroMap>, ) -> LoroResult<Arc<LoroMap>>
pub fn insert_text_container( &self, pos: u32, child: Arc<LoroText>, ) -> LoroResult<Arc<LoroText>>
pub fn insert_tree_container( &self, pos: u32, child: Arc<LoroTree>, ) -> LoroResult<Arc<LoroTree>>
pub fn insert_movable_list_container( &self, pos: u32, child: Arc<LoroMovableList>, ) -> LoroResult<Arc<LoroMovableList>>
pub fn insert_counter_container( &self, pos: u32, child: Arc<LoroCounter>, ) -> LoroResult<Arc<LoroCounter>>
pub fn set_list_container( &self, pos: u32, child: Arc<LoroList>, ) -> LoroResult<Arc<LoroList>>
pub fn set_map_container( &self, pos: u32, child: Arc<LoroMap>, ) -> LoroResult<Arc<LoroMap>>
pub fn set_text_container( &self, pos: u32, child: Arc<LoroText>, ) -> LoroResult<Arc<LoroText>>
pub fn set_tree_container( &self, pos: u32, child: Arc<LoroTree>, ) -> LoroResult<Arc<LoroTree>>
pub fn set_movable_list_container( &self, pos: u32, child: Arc<LoroMovableList>, ) -> LoroResult<Arc<LoroMovableList>>
pub fn set_counter_container( &self, pos: u32, child: Arc<LoroCounter>, ) -> LoroResult<Arc<LoroCounter>>
Sourcepub fn set(&self, pos: u32, value: Arc<dyn LoroValueLike>) -> LoroResult<()>
pub fn set(&self, pos: u32, value: Arc<dyn LoroValueLike>) -> LoroResult<()>
Set the value at the given position.
Sourcepub fn mov(&self, from: u32, to: u32) -> LoroResult<()>
pub fn mov(&self, from: u32, to: u32) -> LoroResult<()>
Move the value at the given position to the given position.
Sourcepub fn get_cursor(&self, pos: u32, side: Side) -> Option<Arc<Cursor>>
pub fn get_cursor(&self, pos: u32, side: Side) -> Option<Arc<Cursor>>
Get the cursor at the given position.
Using “index” to denote cursor positions can be unstable, as positions may shift with document edits. To reliably represent a position or range within a document, it is more effective to leverage the unique ID of each item/character in a List CRDT or Text CRDT.
Loro optimizes State metadata by not storing the IDs of deleted elements. This approach complicates tracking cursors since they rely on these IDs. The solution recalculates position by replaying relevant history to update stable positions accurately. To minimize the performance impact of history replay, the system updates cursor info to reference only the IDs of currently present elements, thereby reducing the need for replay.
pub fn to_vec(&self) -> Vec<LoroValue>
pub fn clear(&self) -> LoroResult<()>
pub fn is_deleted(&self) -> bool
pub fn get_creator_at(&self, index: u32) -> Option<PeerID>
pub fn get_last_mover_at(&self, index: u32) -> Option<PeerID>
pub fn get_last_editor_at(&self, index: u32) -> Option<PeerID>
pub fn doc(&self) -> Option<Arc<LoroDoc>>
pub fn subscribe( &self, subscriber: Arc<dyn Subscriber>, ) -> Option<Arc<Subscription>>
Trait Implementations§
Source§impl Clone for LoroMovableList
impl Clone for LoroMovableList
Source§fn clone(&self) -> LoroMovableList
fn clone(&self) -> LoroMovableList
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LoroMovableList
impl Debug for LoroMovableList
Auto Trait Implementations§
impl Freeze for LoroMovableList
impl RefUnwindSafe for LoroMovableList
impl Send for LoroMovableList
impl Sync for LoroMovableList
impl Unpin for LoroMovableList
impl UnwindSafe for LoroMovableList
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);