pub enum LoroValue {
Null,
Bool(bool),
Double(f64),
I64(i64),
Binary(Arc<Vec<u8>>),
String(Arc<String>),
List(Arc<Vec<LoroValue>>),
Map(Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>),
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(Arc<Vec<u8>>)
String(Arc<String>)
List(Arc<Vec<LoroValue>>)
Map(Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>)
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 Arc<Vec<u8>>>
pub fn as_binary_mut(&mut self) -> Option<&mut Arc<Vec<u8>>>
Optionally returns mutable references to the inner fields if this is a LoroValue::Binary
, otherwise None
sourcepub fn as_binary(&self) -> Option<&Arc<Vec<u8>>>
pub fn as_binary(&self) -> Option<&Arc<Vec<u8>>>
Optionally returns references to the inner fields if this is a LoroValue::Binary
, otherwise None
sourcepub fn into_binary(self) -> Result<Arc<Vec<u8>>, LoroValue>
pub fn into_binary(self) -> Result<Arc<Vec<u8>>, 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 Arc<String>>
pub fn as_string_mut(&mut self) -> Option<&mut Arc<String>>
Optionally returns mutable references to the inner fields if this is a LoroValue::String
, otherwise None
sourcepub fn as_string(&self) -> Option<&Arc<String>>
pub fn as_string(&self) -> Option<&Arc<String>>
Optionally returns references to the inner fields if this is a LoroValue::String
, otherwise None
sourcepub fn into_string(self) -> Result<Arc<String>, LoroValue>
pub fn into_string(self) -> Result<Arc<String>, 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 Arc<Vec<LoroValue>>>
pub fn as_list_mut(&mut self) -> Option<&mut Arc<Vec<LoroValue>>>
Optionally returns mutable references to the inner fields if this is a LoroValue::List
, otherwise None
sourcepub fn as_list(&self) -> Option<&Arc<Vec<LoroValue>>>
pub fn as_list(&self) -> Option<&Arc<Vec<LoroValue>>>
Optionally returns references to the inner fields if this is a LoroValue::List
, otherwise None
sourcepub fn into_list(self) -> Result<Arc<Vec<LoroValue>>, LoroValue>
pub fn into_list(self) -> Result<Arc<Vec<LoroValue>>, 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 Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>>
pub fn as_map_mut( &mut self ) -> Option<&mut Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>>
Optionally returns mutable references to the inner fields if this is a LoroValue::Map
, otherwise None
sourcepub fn as_map(
&self
) -> Option<&Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>>
pub fn as_map( &self ) -> Option<&Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>>
Optionally returns references to the inner fields if this is a LoroValue::Map
, otherwise None
sourcepub fn into_map(
self
) -> Result<Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>, LoroValue>
pub fn into_map( self ) -> Result<Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>, 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
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§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 From<ContainerID> for LoroValue
impl From<ContainerID> for LoroValue
source§fn from(v: ContainerID) -> LoroValue
fn from(v: ContainerID) -> LoroValue
source§impl PartialEq for LoroValue
impl PartialEq for 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> 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 more