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
impl Any
pub fn cast<T>(self) -> Result<T, 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<'_>>
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<'de> Deserialize<'de> for Any
impl<'de> Deserialize<'de> for Any
§fn deserialize<D>(
deserializer: D,
) -> Result<Any, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
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<'de, 'a> IntoDeserializer<'de, Error> for &'a Anywhere
'a: 'de,
impl<'de, 'a> IntoDeserializer<'de, Error> for &'a Anywhere
'a: 'de,
§type Deserializer = AnyDeserializer<'de>
type Deserializer = AnyDeserializer<'de>
The type of the deserializer being converted into.
§fn into_deserializer(
self,
) -> <&'a Any as IntoDeserializer<'de, Error>>::Deserializer
fn into_deserializer( self, ) -> <&'a Any as IntoDeserializer<'de, Error>>::Deserializer
Convert this value into a deserializer.
§impl JsonPathEval for Any
impl JsonPathEval for Any
§fn json_path<'a>(
&'a self,
path: &'a JsonPath<'a>,
) -> <Any as JsonPathEval>::Iter<'a>
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 Serialize for Any
impl Serialize for Any
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
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 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Prelim for T
impl<T> Prelim for T
§fn into_content(self, _txn: &mut TransactionMut<'_>) -> (ItemContent, Option<T>)
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)
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.
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.