pub enum LoroValue {
Null,
Bool(bool),
Double(f64),
I64(i64),
Binary(LoroBinaryValue),
String(LoroStringValue),
List(LoroListValue),
Map(LoroMapValue),
Container(ContainerID),
}Expand description
LoroValue is used to represents the state of CRDT at a given version.
This struct is cheap to clone, the time complexity is O(1).
Variants§
Null
Bool(bool)
Double(f64)
I64(i64)
Binary(LoroBinaryValue)
String(LoroStringValue)
List(LoroListValue)
Map(LoroMapValue)
Container(ContainerID)
Implementations§
Source§impl LoroValue
impl LoroValue
Sourcepub fn as_bool_mut(&mut self) -> Option<&mut bool>
pub fn as_bool_mut(&mut self) -> Option<&mut bool>
Optionally returns mutable references to the inner fields if this is a LoroValue::Bool, otherwise None
Sourcepub fn as_bool(&self) -> Option<&bool>
pub fn as_bool(&self) -> Option<&bool>
Optionally returns references to the inner fields if this is a LoroValue::Bool, otherwise None
Sourcepub fn into_bool(self) -> Result<bool, LoroValue>
pub fn into_bool(self) -> Result<bool, LoroValue>
Returns the inner fields if this is a LoroValue::Bool, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_double_mut(&mut self) -> Option<&mut f64>
pub fn as_double_mut(&mut self) -> Option<&mut f64>
Optionally returns mutable references to the inner fields if this is a LoroValue::Double, otherwise None
Sourcepub fn as_double(&self) -> Option<&f64>
pub fn as_double(&self) -> Option<&f64>
Optionally returns references to the inner fields if this is a LoroValue::Double, otherwise None
Sourcepub fn into_double(self) -> Result<f64, LoroValue>
pub fn into_double(self) -> Result<f64, LoroValue>
Returns the inner fields if this is a LoroValue::Double, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_i64_mut(&mut self) -> Option<&mut i64>
pub fn as_i64_mut(&mut self) -> Option<&mut i64>
Optionally returns mutable references to the inner fields if this is a LoroValue::I64, otherwise None
Sourcepub fn as_i64(&self) -> Option<&i64>
pub fn as_i64(&self) -> Option<&i64>
Optionally returns references to the inner fields if this is a LoroValue::I64, otherwise None
Sourcepub fn into_i64(self) -> Result<i64, LoroValue>
pub fn into_i64(self) -> Result<i64, LoroValue>
Returns the inner fields if this is a LoroValue::I64, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_binary_mut(&mut self) -> Option<&mut LoroBinaryValue>
pub fn as_binary_mut(&mut self) -> Option<&mut LoroBinaryValue>
Optionally returns mutable references to the inner fields if this is a LoroValue::Binary, otherwise None
Sourcepub fn as_binary(&self) -> Option<&LoroBinaryValue>
pub fn as_binary(&self) -> Option<&LoroBinaryValue>
Optionally returns references to the inner fields if this is a LoroValue::Binary, otherwise None
Sourcepub fn into_binary(self) -> Result<LoroBinaryValue, LoroValue>
pub fn into_binary(self) -> Result<LoroBinaryValue, LoroValue>
Returns the inner fields if this is a LoroValue::Binary, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_string_mut(&mut self) -> Option<&mut LoroStringValue>
pub fn as_string_mut(&mut self) -> Option<&mut LoroStringValue>
Optionally returns mutable references to the inner fields if this is a LoroValue::String, otherwise None
Sourcepub fn as_string(&self) -> Option<&LoroStringValue>
pub fn as_string(&self) -> Option<&LoroStringValue>
Optionally returns references to the inner fields if this is a LoroValue::String, otherwise None
Sourcepub fn into_string(self) -> Result<LoroStringValue, LoroValue>
pub fn into_string(self) -> Result<LoroStringValue, LoroValue>
Returns the inner fields if this is a LoroValue::String, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_list_mut(&mut self) -> Option<&mut LoroListValue>
pub fn as_list_mut(&mut self) -> Option<&mut LoroListValue>
Optionally returns mutable references to the inner fields if this is a LoroValue::List, otherwise None
Sourcepub fn as_list(&self) -> Option<&LoroListValue>
pub fn as_list(&self) -> Option<&LoroListValue>
Optionally returns references to the inner fields if this is a LoroValue::List, otherwise None
Sourcepub fn into_list(self) -> Result<LoroListValue, LoroValue>
pub fn into_list(self) -> Result<LoroListValue, LoroValue>
Returns the inner fields if this is a LoroValue::List, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_map_mut(&mut self) -> Option<&mut LoroMapValue>
pub fn as_map_mut(&mut self) -> Option<&mut LoroMapValue>
Optionally returns mutable references to the inner fields if this is a LoroValue::Map, otherwise None
Sourcepub fn as_map(&self) -> Option<&LoroMapValue>
pub fn as_map(&self) -> Option<&LoroMapValue>
Optionally returns references to the inner fields if this is a LoroValue::Map, otherwise None
Sourcepub fn into_map(self) -> Result<LoroMapValue, LoroValue>
pub fn into_map(self) -> Result<LoroMapValue, LoroValue>
Returns the inner fields if this is a LoroValue::Map, otherwise returns back the enum in the Err case of the result
Sourcepub fn is_container(&self) -> bool
pub fn is_container(&self) -> bool
Returns true if this is a LoroValue::Container, otherwise false
Sourcepub fn as_container_mut(&mut self) -> Option<&mut ContainerID>
pub fn as_container_mut(&mut self) -> Option<&mut ContainerID>
Optionally returns mutable references to the inner fields if this is a LoroValue::Container, otherwise None
Sourcepub fn as_container(&self) -> Option<&ContainerID>
pub fn as_container(&self) -> Option<&ContainerID>
Optionally returns references to the inner fields if this is a LoroValue::Container, otherwise None
Sourcepub fn into_container(self) -> Result<ContainerID, LoroValue>
pub fn into_container(self) -> Result<ContainerID, LoroValue>
Returns the inner fields if this is a LoroValue::Container, otherwise returns back the enum in the Err case of the result
Source§impl LoroValue
impl LoroValue
pub fn get_by_key(&self, key: &str) -> Option<&LoroValue>
pub fn get_by_index(&self, index: isize) -> Option<&LoroValue>
pub fn is_false(&self) -> bool
pub fn get_depth(&self) -> usize
pub fn is_too_deep(&self) -> bool
Sourcepub fn visit_children(&self, f: &mut dyn FnMut(&LoroValue))
pub fn visit_children(&self, f: &mut dyn FnMut(&LoroValue))
Visit the all list items or map’s values
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for LoroValue
impl<'a> Arbitrary<'a> for LoroValue
Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<LoroValue, Error>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<LoroValue, Error>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for LoroValue
impl<'de> Deserialize<'de> for LoroValue
Source§fn deserialize<D>(
deserializer: D,
) -> Result<LoroValue, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<LoroValue, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl EstimatedSize for LoroValue
impl EstimatedSize for LoroValue
Source§fn estimate_storage_size(&self) -> usize
fn estimate_storage_size(&self) -> usize
Source§impl From<ContainerID> for LoroValue
impl From<ContainerID> for LoroValue
Source§fn from(v: ContainerID) -> LoroValue
fn from(v: ContainerID) -> LoroValue
Source§impl From<LoroValue> for ValueOrHandler
impl From<LoroValue> for ValueOrHandler
Source§impl FromIterator<LoroValue> for LoroListValue
impl FromIterator<LoroValue> for LoroListValue
Source§fn from_iter<T>(iter: T) -> LoroListValuewhere
T: IntoIterator<Item = LoroValue>,
fn from_iter<T>(iter: T) -> LoroListValuewhere
T: IntoIterator<Item = LoroValue>,
Source§impl Serialize for LoroValue
impl Serialize for LoroValue
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl TryFrom<LoroValue> for ContainerID
impl TryFrom<LoroValue> for ContainerID
impl Eq for LoroValue
impl StructuralPartialEq for LoroValue
Auto Trait Implementations§
impl Freeze for LoroValue
impl RefUnwindSafe for LoroValue
impl Send for LoroValue
impl Sync for LoroValue
impl Unpin for LoroValue
impl UnwindSafe for LoroValue
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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>
Returns self with the
fg()
set to
Color::BrightBlack.
§Example
println!("{}", value.bright_black());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>
Returns self with the
fg()
set to
Color::BrightGreen.
§Example
println!("{}", value.bright_green());Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Returns self with the
fg()
set to
Color::BrightYellow.
§Example
println!("{}", value.bright_yellow());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>
Returns self with the
fg()
set to
Color::BrightMagenta.
§Example
println!("{}", value.bright_magenta());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>
Returns self with the
fg()
set to
Color::BrightWhite.
§Example
println!("{}", value.bright_white());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>
Returns self with the
bg()
set to
Color::BrightBlack.
§Example
println!("{}", value.on_bright_black());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>
Returns self with the
bg()
set to
Color::BrightGreen.
§Example
println!("{}", value.on_bright_green());Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightYellow.
§Example
println!("{}", value.on_bright_yellow());Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightBlue.
§Example
println!("{}", value.on_bright_blue());Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightMagenta.
§Example
println!("{}", value.on_bright_magenta());Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightCyan.
§Example
println!("{}", value.on_bright_cyan());Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightWhite.
§Example
println!("{}", value.on_bright_white());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 underline(&self) -> Painted<&T>
fn underline(&self) -> Painted<&T>
Returns self with the
attr()
set to
Attribute::Underline.
§Example
println!("{}", value.underline());Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Returns self with the
attr()
set to
Attribute::RapidBlink.
§Example
println!("{}", value.rapid_blink());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);