Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica

Any

Enum Any 

pub enum Any {
    Null,
    Undefined,
    Bool(bool),
    Number(f64),
    BigInt(i64),
    String(Arc<str>),
    Buffer(Arc<[u8]>),
    Array(Arc<[Any]>),
    Map(Arc<HashMap<String, Any>>),
}
Expand description

Any is an enum with a potentially associated value that is used to represent JSON values and supports efficient encoding of those values.

Variants§

§

Null

§

Undefined

§

Bool(bool)

§

Number(f64)

§

BigInt(i64)

§

String(Arc<str>)

§

Buffer(Arc<[u8]>)

§

Array(Arc<[Any]>)

§

Map(Arc<HashMap<String, Any>>)

Implementations§

§

impl Any

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

pub fn decode<R>(decoder: &mut R) -> Result<Any, Error>
where R: Read,

pub fn encode<W>(&self, encoder: &mut W)
where W: Write,

pub fn from_json(src: &str) -> Result<Any, Error>

pub fn to_json(&self, buf: &mut String)

pub fn try_iter(&self) -> Option<AnyIter<'_>>

Returns an iterator over an inner values of an array or a map, current reference represents.

pub fn try_into_iter(self) -> Option<AnyIntoIter>

Trait Implementations§

§

impl Clone for Any

§

fn clone(&self) -> Any

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
§

impl Debug for Any

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Any

§

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

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

impl Display for Any

§

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

Formats the value using the given formatter. Read more
§

impl From<&[u8]> for Any

§

fn from(value: &[u8]) -> Any

Converts to this type from the input type.
§

impl From<&str> for Any

§

fn from(value: &str) -> Any

Converts to this type from the input type.
§

impl From<Any> for In

§

fn from(value: Any) -> In

Converts to this type from the input type.
§

impl From<Arc<[u8]>> for Any

§

fn from(value: Arc<[u8]>) -> Any

Converts to this type from the input type.
§

impl From<Arc<str>> for Any

§

fn from(value: Arc<str>) -> Any

Converts to this type from the input type.
§

impl<T> From<HashMap<String, T>> for Any
where T: Into<Any>,

§

fn from(v: HashMap<String, T>) -> Any

Converts to this type from the input type.
§

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

§

fn from(v: Option<T>) -> Any

Converts to this type from the input type.
§

impl From<String> for Any

§

fn from(value: String) -> Any

Converts to this type from the input type.
§

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

§

fn from(v: Vec<T>) -> Any

Converts to this type from the input type.
§

impl From<Vec<u8>> for Any

§

fn from(value: Vec<u8>) -> Any

Converts to this type from the input type.
§

impl From<bool> for Any

§

fn from(value: bool) -> Any

Converts to this type from the input type.
§

impl From<f32> for Any

§

fn from(v: f32) -> Any

Converts to this type from the input type.
§

impl From<f64> for Any

§

fn from(v: f64) -> Any

Converts to this type from the input type.
§

impl From<i16> for Any

§

fn from(v: i16) -> Any

Converts to this type from the input type.
§

impl From<i32> for Any

§

fn from(v: i32) -> Any

Converts to this type from the input type.
§

impl From<i64> for Any

§

fn from(value: i64) -> Any

Converts to this type from the input type.
§

impl From<isize> for Any

§

fn from(value: isize) -> Any

Converts to this type from the input type.
§

impl From<u16> for Any

§

fn from(v: u16) -> Any

Converts to this type from the input type.
§

impl From<u32> for Any

§

fn from(v: u32) -> Any

Converts to this type from the input type.
§

impl<'de, 'a> IntoDeserializer<'de, Error> for &'a Any
where 'a: 'de,

§

type Deserializer = AnyDeserializer<'de>

The type of the deserializer being converted into.
§

fn into_deserializer( self, ) -> <&'a Any as IntoDeserializer<'de, Error>>::Deserializer

Convert this value into a deserializer.
§

impl JsonPathEval for Any

§

fn json_path<'a>( &'a self, path: &'a JsonPath<'a>, ) -> <Any as JsonPathEval>::Iter<'a>

Evaluate JSON path on the current object.

§Example
use yrs::{any, Any, JsonPath, JsonPathEval};

let root = any!({
   "users": [
      {
        "name": "Alice",
        "surname": "Smith",
        "age": 25,
        "friends": [
          { "name": "Bob", "nick": "boreas" },
          { "nick": "crocodile91" }
        ]
     },
   ]
});

let query = JsonPath::parse("$.users..friends.*.nick").unwrap();
let values: Vec<&Any> = root.json_path(&query).collect();
assert_eq!(values, vec![&any!("boreas"), &any!("crocodile91")]);
§

type Iter<'a> = JsonPathIter<'a>

§

impl PartialEq for Any

§

fn eq(&self, other: &Any) -> 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.
§

impl Serialize for Any

§

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
§

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

§

type Error = Any

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

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

Performs the conversion.
§

impl TryFrom<Any> for Arc<str>

§

type Error = Any

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

fn try_from(v: Any) -> Result<Arc<str>, <Arc<str> as TryFrom<Any>>::Error>

Performs the conversion.
§

impl TryFrom<Any> for String

§

type Error = Any

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

fn try_from(v: Any) -> Result<String, <String as TryFrom<Any>>::Error>

Performs the conversion.
§

impl TryFrom<Any> for Vec<u8>

§

type Error = Any

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

fn try_from(v: Any) -> Result<Vec<u8>, <Vec<u8> as TryFrom<Any>>::Error>

Performs the conversion.
§

impl TryFrom<ItemPtr> for Any

§

type Error = ItemPtr

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

fn try_from(item: ItemPtr) -> Result<Any, <Any as TryFrom<ItemPtr>>::Error>

Performs the conversion.
§

impl TryFrom<u64> for Any

§

type Error = u64

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

fn try_from(value: u64) -> Result<Any, <Any as TryFrom<u64>>::Error>

Performs the conversion.
§

impl TryFrom<usize> for Any

§

type Error = usize

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

fn try_from(value: usize) -> Result<Any, <Any as TryFrom<usize>>::Error>

Performs the conversion.
§

impl StructuralPartialEq for Any

Auto Trait Implementations§

§

impl Freeze for Any

§

impl RefUnwindSafe for Any

§

impl Send for Any

§

impl Sync for Any

§

impl Unpin for Any

§

impl UnwindSafe for Any

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
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

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
§

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
§

impl<T> Prelim for T
where T: Into<Any>,

§

type Return = Unused

Type of a value to be returned as a result of inserting this Prelim type instance. Use Unused if none is necessary.
§

fn into_content(self, _txn: &mut TransactionMut<'_>) -> (ItemContent, Option<T>)

This method is used to create initial content required in order to create a block item. A supplied ptr can be used to identify block that is about to be created to store the returned content. Read more
§

fn integrate(self, _txn: &mut TransactionMut<'_>, _inner_ref: BranchPtr)

Method called once an original item filled with content from Self::into_content has been added to block store. This method is used by complex types such as maps or arrays to append the original contents of prelim struct into YMap, YArray etc.
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
§

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

§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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