Skip to main content

Value

Enum Value 

Source
pub enum Value {
    Null,
    Boolean(bool),
    Number(NumberBuf<SmallVec<[u8; 16]>>),
    String(CompactString),
    Array(Vec<Value>),
    Object(Object),
}
Expand description

JSON Value.

§Parsing

You can parse a Value by importing the Parse trait providing a collection of parsing functions.

§Example

use jstrict::{Value, Parse, CodeMap};
let (value, code_map) = Value::parse_str("{ \"key\": \"value\" }").unwrap();

The code_map value of type CodeMap contains code-mapping information about all the fragments of the JSON value (their location in the source text).

§Comparison

This type implements the usual comparison traits PartialEq, Eq, PartialOrd and Ord. However by default JSON object entries ordering matters, meaning that { "a": 0, "b": 1 } is not equal to { "b": 1, "a": 0 }. If you want to do comparisons while ignoring entries ordering, you can use the Unordered type (combined with the UnorderedPartialEq trait). Any T reference can be turned into an Unordered<T> reference at will using the BorrowUnordered::as_unordered method.

§Example

use jstrict::{json, Unordered, BorrowUnordered};

let a = json!({ "a": 0, "b": 1 });
let b = json!({ "b": 1, "a": 0 });

assert_ne!(a, b); // not equals entries are in a different order.
assert_eq!(a.as_unordered(), b.as_unordered()); // equals modulo entry order.
assert_eq!(Unordered(a), Unordered(b)); // equals modulo entry order.

§Printing

The Print trait provide a highly configurable printing method.

§Example

use jstrict::{Value, Parse, Print};

let value = Value::parse_str("[ 0, 1, { \"key\": \"value\" }, null ]").unwrap().0;

println!("{}", value.pretty_print()); // multi line, indent with 2 spaces
println!("{}", value.inline_print()); // single line, spaces
println!("{}", value.compact_print()); // single line, no spaces

let mut options = jstrict::print::Options::pretty();
options.indent = jstrict::print::Indent::Tabs(1);
println!("{}", value.print_with(options)); // multi line, indent with tabs

Variants§

§

Null

null.

§

Boolean(bool)

Boolean true or false.

§

Number(NumberBuf<SmallVec<[u8; 16]>>)

Number.

§

String(CompactString)

String.

§

Array(Vec<Value>)

Array.

§

Object(Object)

Object.

Implementations§

Source§

impl Value

Source

pub fn from_serde_json(value: Value) -> Value

Converts a serde_json::Value into a Value.

§Example
// First we create a `serde_json` value.
let a = serde_json::json!({
  "foo": 1,
  "bar": [2, 3]
});

// We convert the `serde_json` value into a `jstrict` value.
let b = jstrict::Value::from_serde_json(a);

// We convert it back into a `serde_json` value.
let _ = jstrict::Value::into_serde_json(b);
Source

pub fn into_serde_json(self) -> Value

Converts a Value into a serde_json::Value.

§Example
// First we create a `serde_json` value.
let a = serde_json::json!({
  "foo": 1,
  "bar": [2, 3]
});

// We convert the `serde_json` value into a `jstrict` value.
let b = jstrict::Value::from_serde_json(a);

// We convert it back into a `serde_json` value.
let _ = jstrict::Value::into_serde_json(b);
Source§

impl Value

Source

pub fn from_sonic_rs(value: &Value) -> Value

Converts a sonic_rs::Value into a Value.

§Example
// First we create a `sonic_rs` value.
let a = sonic_rs::json!({
  "foo": 1,
  "bar": [2, 3]
});

// We convert the `sonic_rs` value into a `jstrict` value.
let b = jstrict::Value::from_sonic_rs(&a);

// We convert it back into a `sonic_rs` value.
let _ = jstrict::Value::into_sonic_rs(b);
Source

pub fn into_sonic_rs(self) -> Value

Converts a Value into a sonic_rs::Value.

§Example
// First we create a `sonic_rs` value.
let a = sonic_rs::json!({
  "foo": 1,
  "bar": [2, 3]
});

// We convert the `sonic_rs` value into a `jstrict` value.
let b = jstrict::Value::from_sonic_rs(&a);

// We convert it back into a `sonic_rs` value.
let _ = jstrict::Value::into_sonic_rs(b);
Source§

impl Value

Source

pub fn get_fragment(&self, index: usize) -> Result<FragmentRef<'_>, usize>

Returns the fragment at the given index in traversal order, where index 0 is self.

Fragment indices match CodeMap offsets: the fragment returned for index i is described by code_map[offset + i]. On failure, returns the number of fragments left to skip.

§Errors

Returns the number of fragments left to skip past self when index does not resolve to a fragment within it.

Source

pub const fn kind(&self) -> Kind

Returns the Kind of this value.

Source

pub fn is_kind(&self, kind: Kind) -> bool

Checks if this value is of the given kind.

Source

pub const fn is_null(&self) -> bool

Checks if this value is null.

Source

pub const fn is_boolean(&self) -> bool

Checks if this value is a boolean.

Source

pub const fn is_number(&self) -> bool

Checks if this value is a number.

Source

pub const fn is_string(&self) -> bool

Checks if this value is a string.

Source

pub const fn is_array(&self) -> bool

Checks if this value is an array.

Source

pub const fn is_object(&self) -> bool

Checks if this value is an object.

Source

pub const fn is_empty_array_or_object(&self) -> bool

Checks if the value is either an empty array or an empty object.

Source

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

Returns this value as a bool, if it is a boolean.

Source

pub const fn as_boolean_mut(&mut self) -> Option<&mut bool>

Returns a mutable reference to the inner bool, if this is a boolean.

Source

pub fn as_number(&self) -> Option<&Number>

Returns this value as a Number, if it is a number.

Source

pub const fn as_number_mut( &mut self, ) -> Option<&mut NumberBuf<SmallVec<[u8; 16]>>>

Returns a mutable reference to the inner number buffer, if this is a number.

Source

pub fn as_string(&self) -> Option<&str>

Returns this value as a &str, if it is a string.

Source

pub fn as_str(&self) -> Option<&str>

Alias for as_string.

Source

pub const fn as_string_mut(&mut self) -> Option<&mut CompactString>

Returns a mutable reference to the inner string, if this is a string.

Source

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

Returns this value as a slice of values, if it is an array.

Source

pub const fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>

Returns a mutable reference to the inner array, if this is an array.

Source

pub fn force_as_array(&self) -> &[Value]

Return the given value as an array, even if it is not an array.

Returns the input value as is if it is already an array, or puts it in a slice with a single element if it is not.

Source

pub const fn as_object(&self) -> Option<&Object>

Returns this value as an Object, if it is an object.

Source

pub const fn as_object_mut(&mut self) -> Option<&mut Object>

Returns a mutable reference to the inner object, if this is an object.

Source

pub fn into_boolean(self) -> Option<bool>

Consumes this value, returning the inner bool if it is a boolean.

Source

pub fn into_number(self) -> Option<NumberBuf<SmallVec<[u8; 16]>>>

Consumes this value, returning the inner number if it is a number.

Source

pub fn into_string(self) -> Option<CompactString>

Consumes this value, returning the inner string if it is a string.

Source

pub fn into_array(self) -> Option<Vec<Value>>

Consumes this value, returning the inner array if it is an array.

Source

pub fn into_object(self) -> Option<Object>

Consumes this value, returning the inner object if it is an object.

Source

pub fn traverse(&self) -> Traverse<'_> ⓘ

Returns an iterator over every fragment of this value, in depth-first order, paired with its index.

The index of each fragment is its offset in the CodeMap produced when the value was parsed.

Source

pub fn count(&self, f: impl FnMut(usize, FragmentRef<'_>) -> bool) -> usize

Recursively count the number of values for which f returns true.

Source

pub fn volume(&self) -> usize

Returns the volume of the value.

The volume is the sum of all values and recursively nested values included in self, including self (the volume is at least 1).

This is equivalent to value.traverse().filter(|(_, f)| f.is_value()).count().

Source

pub const fn take(&mut self) -> Value

Move and return the value, leaves null in its place.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Compare for Value

Source§

fn compare(&self, other: &Self) -> bool

Checks whether the two values are equal, up to the order of array items and object entries. 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<'de> Deserialize<'de> for Value

Source§

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

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

impl<'de> Deserializer<'de> for Value

Source§

type Error = DeserializeError

The error type that can be returned if some error occurs during deserialization.
Source§

fn deserialize_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
Source§

fn deserialize_i8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
Source§

fn deserialize_i16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
Source§

fn deserialize_i32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
Source§

fn deserialize_i64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
Source§

fn deserialize_i128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
Source§

fn deserialize_u8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
Source§

fn deserialize_u16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
Source§

fn deserialize_u32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
Source§

fn deserialize_u64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
Source§

fn deserialize_u128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
Source§

fn deserialize_f32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
Source§

fn deserialize_f64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
Source§

fn deserialize_option<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
Source§

fn deserialize_enum<V>( self, _name: &str, _variants: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
Source§

fn deserialize_newtype_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
Source§

fn deserialize_bool<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
Source§

fn deserialize_char<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
Source§

fn deserialize_str<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_string<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_unit<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
Source§

fn deserialize_unit_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
Source§

fn deserialize_seq<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
Source§

fn deserialize_tuple<V>( self, _len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
Source§

fn deserialize_tuple_struct<V>( self, _name: &'static str, _len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
Source§

fn deserialize_map<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
Source§

fn deserialize_struct<V>( self, _name: &'static str, _fields: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
Source§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
Source§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
Source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. 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 Eq for Value

Source§

impl<'n> From<&'n Number> for Value

Source§

fn from(n: &'n Number) -> Value

Converts to this type from the input type.
Source§

impl<'s> From<&'s str> for Value

Source§

fn from(s: &'s str) -> Value

Converts to this type from the input type.
Source§

impl From<CompactString> for Value

Source§

fn from(s: CompactString) -> Value

Converts to this type from the input type.
Source§

impl From<NumberBuf<SmallVec<[u8; 16]>>> for Value

Source§

fn from(n: NumberBuf<SmallVec<[u8; 16]>>) -> Value

Converts to this type from the input type.
Source§

impl From<Object> for Value

Source§

fn from(o: Object) -> Value

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(s: String) -> Value

Converts to this type from the input type.
Source§

impl From<Value> for Value

Source§

fn from(value: Value) -> Value

Converts to this type from the input type.
Source§

impl From<Value> for Value

Source§

fn from(value: Value) -> Value

Converts to this type from the input type.
Source§

impl From<Vec<Value>> for Value

Source§

fn from(a: Vec<Value>) -> Value

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(b: bool) -> Value

Converts to this type from the input type.
Source§

impl From<i8> for Value

Source§

fn from(n: i8) -> Value

Converts to this type from the input type.
Source§

impl From<i16> for Value

Source§

fn from(n: i16) -> Value

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(n: i32) -> Value

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(n: i64) -> Value

Converts to this type from the input type.
Source§

impl From<u8> for Value

Source§

fn from(n: u8) -> Value

Converts to this type from the input type.
Source§

impl From<u16> for Value

Source§

fn from(n: u16) -> Value

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(n: u32) -> Value

Converts to this type from the input type.
Source§

impl From<u64> for Value

Source§

fn from(n: u64) -> Value

Converts to this type from the input type.
Source§

impl FromStr for Value

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Value, <Value as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Value

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoDeserializer<'_, DeserializeError> for Value

Source§

type Deserializer = Value

The type of the deserializer being converted into.
Source§

fn into_deserializer( self, ) -> <Value as IntoDeserializer<'_, DeserializeError>>::Deserializer

Convert this value into a deserializer.
Source§

impl Ord for Value

Source§

fn cmp(&self, other: &Value) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl Parse for Value

Source§

fn parse_str(content: &str) -> Result<(Value, CodeMap), Error>

Parses a value from a string. Read more
Source§

fn parse_str_with( content: &str, options: Options, ) -> Result<(Value, CodeMap), Error>

Parses a value from a string, with the given options. Read more
Source§

fn parse_slice(content: &[u8]) -> Result<(Value, CodeMap), Error>

Parses a value from a UTF-8 byte slice. Read more
Source§

fn parse_slice_with( content: &[u8], options: Options, ) -> Result<(Value, CodeMap), Error>

Parses a value from a UTF-8 byte slice, with the given options. Read more
Source§

fn parse_in<C, E>( parser: &mut Parser<C, E>, context: Context, ) -> Result<(Value, usize), Error<E>>
where C: Iterator<Item = Result<DecodedChar, E>>,

Parses a value in the middle of an ongoing parse, using parser and the surrounding Context. Read more
Source§

fn parse_infallible_utf8<C>(chars: C) -> Result<(Self, CodeMap), Error>
where C: Iterator<Item = char>,

Parses a value from an infallible iterator of UTF-8 characters. Read more
Source§

fn parse_utf8_infallible_with<C>( chars: C, options: Options, ) -> Result<(Self, CodeMap), Error>
where C: Iterator<Item = char>,

Parses a value from an infallible iterator of UTF-8 characters, with the given options. Read more
Source§

fn parse_utf8<C, E>(chars: C) -> Result<(Self, CodeMap), Error<E>>
where C: Iterator<Item = Result<char, E>>,

Parses a value from a fallible iterator of UTF-8 characters. Read more
Source§

fn parse_utf8_with<C, E>( chars: C, options: Options, ) -> Result<(Self, CodeMap), Error<E>>
where C: Iterator<Item = Result<char, E>>,

Parses a value from a fallible iterator of UTF-8 characters, with the given options. Read more
Source§

fn parse_infallible<C>(chars: C) -> Result<(Self, CodeMap), Error>
where C: Iterator<Item = DecodedChar>,

Parses a value from an infallible iterator of decoded characters. Read more
Source§

fn parse_infallible_with<C>( chars: C, options: Options, ) -> Result<(Self, CodeMap), Error>
where C: Iterator<Item = DecodedChar>,

Parses a value from an infallible iterator of decoded characters, with the given options. Read more
Source§

fn parse<C, E>(chars: C) -> Result<(Self, CodeMap), Error<E>>
where C: Iterator<Item = Result<DecodedChar, E>>,

Parses a value from a fallible iterator of decoded characters. Read more
Source§

fn parse_with<C, E>( chars: C, options: Options, ) -> Result<(Self, CodeMap), Error<E>>
where C: Iterator<Item = Result<DecodedChar, E>>,

Parses a value from a fallible iterator of decoded characters, with the given options. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Value

Source§

fn partial_cmp(&self, other: &Value) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PrecomputeSize for Value

Source§

fn pre_compute_size(&self, options: &Options, sizes: &mut Vec<Size>) -> Size

Computes the printed size of this value, appending the size of each nested array and object to sizes.
Source§

impl Print for Value

Source§

fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result<(), Error>

Writes the value to f with the given options, starting at the given indentation level. Read more
Source§

fn pretty_print(&self) -> Printed<'_, Self>

Print the value with Options::pretty options.
Source§

fn compact_print(&self) -> Printed<'_, Self>

Print the value with Options::compact options.
Source§

fn inline_print(&self) -> Printed<'_, Self>

Print the value with Options::inline options.
Source§

fn print_with(&self, options: Options) -> Printed<'_, Self>

Print the value with the given options.
Source§

impl PrintWithSize for Value

Source§

fn fmt_with_size( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, sizes: &[Size], index: &mut usize, ) -> Result<(), Error>

Writes the value to f, taking its layout from sizes[*index]. Read more
Source§

impl Serialize for Value

Source§

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

impl StructuralPartialEq for Value

Source§

impl TryFrom<f32> for Value

Source§

type Error = TryFromFloatError

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

fn try_from(n: f32) -> Result<Value, <Value as TryFrom<f32>>::Error>

Performs the conversion.
Source§

impl TryFrom<f64> for Value

Source§

type Error = TryFromFloatError

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

fn try_from(n: f64) -> Result<Value, <Value as TryFrom<f64>>::Error>

Performs the conversion.
Source§

impl UnorderedEq for Value

Source§

impl UnorderedPartialEq for Value

Source§

fn unordered_eq(&self, other: &Value) -> bool

Checks if self and other are equal modulo object entry order.

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin 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> BorrowUnordered for T

Source§

fn as_unordered(&self) -> &Unordered<T>

Views this value as an Unordered reference.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if self is equivalent to key.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, C> FromWithContext<T, C> for T

Source§

fn from_with(value: T, _context: &C) -> T

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, U, C> IntoWithContext<U, C> for T
where U: FromWithContext<T, C>,

Source§

fn into_with(self, context: &C) -> U

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U, C> TryFromWithContext<U, C> for T
where U: IntoWithContext<T, C>,

Source§

type Error = !

Source§

fn try_from_with( value: U, context: &C, ) -> Result<T, <T as TryFromWithContext<U, C>>::Error>

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<T, U, C> TryIntoWithContext<U, C> for T
where U: TryFromWithContext<T, C>,

Source§

type Error = <U as TryFromWithContext<T, C>>::Error

Source§

fn try_into_with( self, context: &C, ) -> Result<U, <T as TryIntoWithContext<U, C>>::Error>

Source§

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

Source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

Source§

fn into_with<C>(self, context: C) -> Contextual<T, C>
where T: Sized,