Enum json5format::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>,

§

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

§

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.