Enum loro_internal::LoroValue
source · 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 more