Enum loro::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§

Implementations§

source§

impl LoroValue

source

pub fn is_null(&self) -> bool

Returns true if this is a LoroValue::Null, otherwise false

source

pub fn is_bool(&self) -> bool

Returns true if this is a LoroValue::Bool, otherwise false

source

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

source

pub fn as_bool(&self) -> Option<&bool>

Optionally returns references to the inner fields if this is a LoroValue::Bool, otherwise None

source

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

source

pub fn is_double(&self) -> bool

Returns true if this is a LoroValue::Double, otherwise false

source

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

source

pub fn as_double(&self) -> Option<&f64>

Optionally returns references to the inner fields if this is a LoroValue::Double, otherwise None

source

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

source

pub fn is_i64(&self) -> bool

Returns true if this is a LoroValue::I64, otherwise false

source

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

source

pub fn as_i64(&self) -> Option<&i64>

Optionally returns references to the inner fields if this is a LoroValue::I64, otherwise None

source

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

source

pub fn is_binary(&self) -> bool

Returns true if this is a LoroValue::Binary, otherwise false

source

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

source

pub fn as_binary(&self) -> Option<&Arc<Vec<u8>>>

Optionally returns references to the inner fields if this is a LoroValue::Binary, otherwise None

source

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

source

pub fn is_string(&self) -> bool

Returns true if this is a LoroValue::String, otherwise false

source

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

source

pub fn as_string(&self) -> Option<&Arc<String>>

Optionally returns references to the inner fields if this is a LoroValue::String, otherwise None

source

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

source

pub fn is_list(&self) -> bool

Returns true if this is a LoroValue::List, otherwise false

source

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

source

pub fn as_list(&self) -> Option<&Arc<Vec<LoroValue>>>

Optionally returns references to the inner fields if this is a LoroValue::List, otherwise None

source

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

source

pub fn is_map(&self) -> bool

Returns true if this is a LoroValue::Map, otherwise false

source

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

source

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

source

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

source

pub fn is_container(&self) -> bool

Returns true if this is a LoroValue::Container, otherwise false

source

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

source

pub fn as_container(&self) -> Option<&ContainerID>

Optionally returns references to the inner fields if this is a LoroValue::Container, otherwise None

source

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

source

pub fn get_by_key(&self, key: &str) -> Option<&LoroValue>

source

pub fn get_by_index(&self, index: usize) -> Option<&LoroValue>

source

pub fn is_false(&self) -> bool

source

pub fn get_depth(&self) -> usize

source

pub fn is_too_deep(&self) -> bool

Trait Implementations§

source§

impl ApplyDiff for LoroValue

source§

fn apply_diff_shallow(&mut self, diff: &[Diff])

source§

fn apply_diff(&mut self, diff: &[Diff])

source§

fn apply(&mut self, path: &SmallVec<[Index; 4]>, diff: &[Diff])

source§

impl<'a> Arbitrary<'a> for LoroValue

source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<LoroValue, Error>

Generate an arbitrary value of Self from the given unstructured data. Read more
source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
source§

impl Clone for LoroValue

source§

fn clone(&self) -> LoroValue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for LoroValue

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for LoroValue

source§

fn default() -> LoroValue

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for LoroValue

source§

fn deserialize<D>( deserializer: D ) -> Result<LoroValue, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a> From<&'a [LoroValue]> for LoroValue

source§

fn from(v: &'a [LoroValue]) -> LoroValue

Converts to this type from the input type.
source§

impl From<&[u8]> for LoroValue

source§

fn from(vec: &[u8]) -> LoroValue

Converts to this type from the input type.
source§

impl<const N: usize> From<&[u8; N]> for LoroValue

source§

fn from(vec: &[u8; N]) -> LoroValue

Converts to this type from the input type.
source§

impl From<&str> for LoroValue

source§

fn from(v: &str) -> LoroValue

Converts to this type from the input type.
source§

impl From<ContainerID> for LoroValue

source§

fn from(v: ContainerID) -> LoroValue

Converts to this type from the input type.
source§

impl<S, M> From<HashMap<S, LoroValue, M>> for LoroValue
where S: Into<String>,

source§

fn from(map: HashMap<S, LoroValue, M>) -> LoroValue

Converts to this type from the input type.
source§

impl From<String> for LoroValue

source§

fn from(v: String) -> LoroValue

Converts to this type from the input type.
source§

impl<T> From<Vec<T>> for LoroValue
where T: Into<LoroValue>,

source§

fn from(value: Vec<T>) -> LoroValue

Converts to this type from the input type.
source§

impl From<Vec<u8>> for LoroValue

source§

fn from(vec: Vec<u8>) -> LoroValue

Converts to this type from the input type.
source§

impl From<bool> for LoroValue

source§

fn from(v: bool) -> LoroValue

Converts to this type from the input type.
source§

impl From<f64> for LoroValue

source§

fn from(v: f64) -> LoroValue

Converts to this type from the input type.
source§

impl From<i16> for LoroValue

source§

fn from(v: i16) -> LoroValue

Converts to this type from the input type.
source§

impl From<i32> for LoroValue

source§

fn from(v: i32) -> LoroValue

Converts to this type from the input type.
source§

impl From<i64> for LoroValue

source§

fn from(v: i64) -> LoroValue

Converts to this type from the input type.
source§

impl From<u16> for LoroValue

source§

fn from(v: u16) -> LoroValue

Converts to this type from the input type.
source§

impl From<u32> for LoroValue

source§

fn from(v: u32) -> LoroValue

Converts to this type from the input type.
source§

impl Hash for LoroValue

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Index<&str> for LoroValue

§

type Output = LoroValue

The returned type after indexing.
source§

fn index(&self, index: &str) -> &<LoroValue as Index<&str>>::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<usize> for LoroValue

§

type Output = LoroValue

The returned type after indexing.
source§

fn index(&self, index: usize) -> &<LoroValue as Index<usize>>::Output

Performs the indexing (container[index]) operation. Read more
source§

impl PartialEq for LoroValue

source§

fn eq(&self, other: &LoroValue) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for LoroValue

source§

fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ToJson for LoroValue

source§

impl TryFrom<LoroValue> for Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_from( value: LoroValue ) -> Result<Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>>, <Arc<HashMap<String, LoroValue, BuildHasherDefault<FxHasher>>> as TryFrom<LoroValue>>::Error>

Performs the conversion.
source§

impl TryFrom<LoroValue> for Arc<String>

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_from( value: LoroValue ) -> Result<Arc<String>, <Arc<String> as TryFrom<LoroValue>>::Error>

Performs the conversion.
source§

impl TryFrom<LoroValue> for Arc<Vec<LoroValue>>

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_from( value: LoroValue ) -> Result<Arc<Vec<LoroValue>>, <Arc<Vec<LoroValue>> as TryFrom<LoroValue>>::Error>

Performs the conversion.
source§

impl TryFrom<LoroValue> for Arc<Vec<u8>>

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_from( value: LoroValue ) -> Result<Arc<Vec<u8>>, <Arc<Vec<u8>> as TryFrom<LoroValue>>::Error>

Performs the conversion.
source§

impl TryFrom<LoroValue> for ContainerID

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_from( value: LoroValue ) -> Result<ContainerID, <ContainerID as TryFrom<LoroValue>>::Error>

Performs the conversion.
source§

impl Eq for LoroValue

source§

impl StructuralPartialEq for LoroValue

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ZeroElement for T
where T: Default,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> Rleable for T
where T: Clone + PartialEq + Serialize + for<'de> Deserialize<'de>,