Enum yrs::types::Value

source ·
pub enum Value {
    Any(Any),
    YText(TextRef),
    YArray(ArrayRef),
    YMap(MapRef),
    YXmlElement(XmlElementRef),
    YXmlFragment(XmlFragmentRef),
    YXmlText(XmlTextRef),
    YDoc(Doc),
    UndefinedRef(BranchPtr),
}
Expand description

Value that can be returned by Yrs data types. This includes Any which is an extension representation of JSON, but also nested complex collaborative structures specific to Yrs.

Variants§

§

Any(Any)

Any value that it treated as a single element in it’s entirety.

§

YText(TextRef)

Instance of a TextRef.

§

YArray(ArrayRef)

Instance of an ArrayRef.

§

YMap(MapRef)

Instance of a MapRef.

§

YXmlElement(XmlElementRef)

Instance of a XmlElementRef.

§

YXmlFragment(XmlFragmentRef)

Instance of a XmlFragmentRef.

§

YXmlText(XmlTextRef)

Instance of a XmlTextRef.

§

YDoc(Doc)

Subdocument.

§

UndefinedRef(BranchPtr)

Instance of a shared collection of undefined type. Usually happens when it refers to a root type that has not been defined locally. Can also refer to a [WeakRef] if “weak” feature flag was not set.

Implementations§

source§

impl Value

source

pub fn cast<T>(self) -> Result<T, Self>
where T: TryFrom<Self, Error = Self>,

source

pub fn to_string<T: ReadTxn>(self, txn: &T) -> String

Converts current value into stringified representation.

source

pub fn try_branch(&self) -> Option<&Branch>

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

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 Value

source§

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

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

impl Default for Value

source§

fn default() -> Self

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

impl Display for Value

source§

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

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

impl<T> From<T> for Value
where T: Into<Any>,

source§

fn from(v: T) -> Self

Converts to this type from the input type.
source§

impl Into<Value> for BranchPtr

source§

fn into(self) -> Value

Converts current branch data into a Value. It uses a type ref information to resolve, which value variant is a correct one for this branch. Since branch represent only complex types Value::Any will never be returned from this method.

source§

impl PartialEq for Value

source§

fn eq(&self, other: &Value) -> 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 ToJson for Value

source§

fn to_json<T: ReadTxn>(&self, txn: &T) -> Any

Converts current value into Any object equivalent that resembles enhanced JSON payload. Rules are:

source§

impl TryFrom<Value> for Arc<[u8]>

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for Arc<str>

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for ArrayRef

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for Doc

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for MapRef

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for String

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for TextRef

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for Vec<u8>

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for XmlElementRef

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for XmlFragmentRef

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for XmlNode

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for XmlTextRef

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for bool

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for f32

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for f64

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for i16

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for i32

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for i64

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for isize

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for u16

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for u32

§

type Error = Value

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl !UnwindSafe for Value

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, 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> 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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.