json5format

Enum Value

Source
pub enum Value {
    Primitive {
        val: Primitive,
        comments: Comments,
    },
    Array {
        val: Array,
        comments: Comments,
    },
    Object {
        val: Object,
        comments: Comments,
    },
}
Expand description

Represents the possible data types in a JSON5 object. Each variant has a field representing a specialized struct representing the value’s data, and a field for comments (possibly including a line comment and comments appearing immediately before the value). For Object and Array, comments appearing at the end of the the structure are encapsulated inside the appropriate specialized struct.

Variants§

§

Primitive

Represents a non-recursive data type (string, bool, number, or “null”) and its associated comments.

Fields

§val: Primitive

The struct containing the associated value.

§comments: Comments

The associated comments.

§

Array

Represents a JSON5 array and its associated comments.

Fields

§val: Array

The struct containing the associated value.

§comments: Comments

The comments associated with the array.

§

Object

Represents a JSON5 object and its associated comments.

Fields

§val: Object

The struct containing the associated value.

§comments: Comments

The comments associated with the object.

Implementations§

Source§

impl Value

Source

pub fn is_array(&self) -> bool

Returns true for an Array variant.

Source

pub fn is_object(&self) -> bool

Returns true for an Object variant.

Source

pub fn is_primitive(&self) -> bool

Returns true for a Primitive variant.

Source

pub fn comments(&self) -> &Comments

Retrieves an immutable reference to the comments attribute of any variant.

Source

pub fn comments_mut(&mut self) -> &mut Comments

Returns a mutable reference to the comments attribute of any variant.

Source

pub fn has_comments(&mut self) -> bool

Returns true if this value has any block, line, or end-of-line comment(s).

Trait Implementations§

Source§

impl Debug for Value

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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