Value

Enum 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, Value>
where T: TryFrom<Value, Error = Value>,

Source

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

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 duplicate 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<(), Error>

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

impl Default for Value

Source§

fn default() -> Value

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

impl Display for Value

Source§

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

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) -> Value

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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>(&self, txn: &T) -> Any
where T: ReadTxn,

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

Source§

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

Source§

type Error = Value

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

fn try_from( value: Value, ) -> Result<Arc<[u8]>, <Arc<[u8]> as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Arc<str>

Source§

type Error = Value

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

fn try_from( value: Value, ) -> Result<Arc<str>, <Arc<str> as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for ArrayRef

Source§

type Error = Value

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

fn try_from( value: Value, ) -> Result<ArrayRef, <ArrayRef as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Doc

Source§

type Error = Value

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

fn try_from(value: Value) -> Result<Doc, <Doc as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for MapRef

Source§

type Error = Value

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

fn try_from(value: Value) -> Result<MapRef, <MapRef as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for String

Source§

type Error = Value

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

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

Performs the conversion.
Source§

impl TryFrom<Value> for TextRef

Source§

type Error = Value

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

fn try_from(value: Value) -> Result<TextRef, <TextRef as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Vec<u8>

Source§

type Error = Value

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

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

Performs the conversion.
Source§

impl TryFrom<Value> for XmlElementRef

Source§

type Error = Value

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

fn try_from( value: Value, ) -> Result<XmlElementRef, <XmlElementRef as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for XmlFragmentRef

Source§

type Error = Value

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

fn try_from( value: Value, ) -> Result<XmlFragmentRef, <XmlFragmentRef as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for XmlNode

Source§

type Error = Value

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

fn try_from(value: Value) -> Result<XmlNode, <XmlNode as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for XmlTextRef

Source§

type Error = Value

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

fn try_from( value: Value, ) -> Result<XmlTextRef, <XmlTextRef as TryFrom<Value>>::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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

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

Source§

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>,

Source§

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> ErasedDestructor for T
where T: 'static,