Skip to main content

Node

Trait Node 

Source
pub trait Node<'a, F: Json>: Clone {
    type Object: Object<'a, F, Node = Self>;
    type Array: Array<'a, F, Node = Self>;
    type Number: JsonNumber;

Show 14 methods // Required methods fn as_object(&self) -> Option<Self::Object>; fn as_array(&self) -> Option<Self::Array>; fn as_string(&self) -> Option<Cow<'a, str>>; fn as_number(&self) -> Option<Self::Number>; fn as_boolean(&self) -> Option<bool>; fn is_null(&self) -> bool; fn json_type(&self) -> JsonType; fn to_value(&self) -> Cow<'a, Value>; fn identity(&self) -> Option<NodeIdentity>; // Provided methods fn is_number(&self) -> bool { ... } fn is_string(&self) -> bool { ... } fn string_length(&self) -> Option<u64> { ... } fn equals_value(&self, expected: &Value) -> bool { ... } fn container_identity(&self) -> Option<NodeIdentity> { ... }
}
Expand description

One JSON value; Clone must be cheap.

Required Associated Types§

Source

type Object: Object<'a, F, Node = Self>

Source

type Array: Array<'a, F, Node = Self>

Source

type Number: JsonNumber

Required Methods§

Source

fn as_object(&self) -> Option<Self::Object>

Source

fn as_array(&self) -> Option<Self::Array>

Source

fn as_string(&self) -> Option<Cow<'a, str>>

Source

fn as_number(&self) -> Option<Self::Number>

Source

fn as_boolean(&self) -> Option<bool>

Source

fn is_null(&self) -> bool

Source

fn json_type(&self) -> JsonType

Numbers always report JsonType::Number; integer-ness is a numeric property, not a type.

Source

fn to_value(&self) -> Cow<'a, Value>

For cold paths only: error construction, annotations, the equals_value and is_unique defaults (const/enum/uniqueItems), and serde-only custom keywords.

Source

fn identity(&self) -> Option<NodeIdentity>

Identity for $ref cycle detection and is_valid memoization.

Nodes alive at once must never share one, and two handles on a node must report the same one, or a collision reports a cycle that is not there. A container’s must never pass to a later node: Node::container_identity keys a cache outliving it. None opts out, leaving recursion bounded only by the stack.

Provided Methods§

Source

fn is_number(&self) -> bool

Must agree with as_number().is_some(); override where as_number has to construct.

Source

fn is_string(&self) -> bool

Source

fn string_length(&self) -> Option<u64>

Length in Unicode code points.

Source

fn equals_value(&self, expected: &Value) -> bool

Equality against a const/enum value; numbers compare mathematically.

Source

fn container_identity(&self) -> Option<NodeIdentity>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a> Node<'a, SerdeJson> for &'a Value

Source§

type Object = &'a Map<String, Value>

Source§

type Array = &'a [Value]

Source§

type Number = &'a Number

Source§

fn as_object(&self) -> Option<&'a Map<String, Value>>

Source§

fn as_array(&self) -> Option<&'a [Value]>

Source§

fn as_string(&self) -> Option<Cow<'a, str>>

Source§

fn as_number(&self) -> Option<&'a Number>

Source§

fn as_boolean(&self) -> Option<bool>

Source§

fn is_null(&self) -> bool

Source§

fn json_type(&self) -> JsonType

Source§

fn string_length(&self) -> Option<u64>

Source§

fn equals_value(&self, expected: &Value) -> bool

Source§

fn to_value(&self) -> Cow<'a, Value>

Source§

fn identity(&self) -> Option<NodeIdentity>

Implementors§