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§
type Object: Object<'a, F, Node = Self>
type Array: Array<'a, F, Node = Self>
type Number: JsonNumber
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
Sourcefn json_type(&self) -> JsonType
fn json_type(&self) -> JsonType
Numbers always report JsonType::Number; integer-ness is a numeric property, not a type.
Sourcefn to_value(&self) -> Cow<'a, Value>
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.
Sourcefn identity(&self) -> Option<NodeIdentity>
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§
Sourcefn is_number(&self) -> bool
fn is_number(&self) -> bool
Must agree with as_number().is_some(); override where as_number has to construct.
fn is_string(&self) -> bool
Sourcefn string_length(&self) -> Option<u64>
fn string_length(&self) -> Option<u64>
Length in Unicode code points.
Sourcefn equals_value(&self, expected: &Value) -> bool
fn equals_value(&self, expected: &Value) -> bool
Equality against a const/enum value; numbers compare mathematically.
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".