Enum DeValue

Source
pub enum DeValue<'i> {
    String(Cow<'i, str>),
    Integer(DeInteger<'i>),
    Float(DeFloat<'i>),
    Boolean(bool),
    Datetime(Datetime),
    Array(DeArray<'i>),
    Table(Map<Spanned<Cow<'i, str>>, Spanned<DeValue<'i>>>),
}
Expand description

Representation of a TOML value.

Variants§

§

String(Cow<'i, str>)

Represents a TOML string

§

Integer(DeInteger<'i>)

Represents a TOML integer

§

Float(DeFloat<'i>)

Represents a TOML float

§

Boolean(bool)

Represents a TOML boolean

§

Datetime(Datetime)

Represents a TOML datetime

§

Array(DeArray<'i>)

Represents a TOML array

§

Table(Map<Spanned<Cow<'i, str>>, Spanned<DeValue<'i>>>)

Represents a TOML table

Implementations§

Source§

impl<'i> DeValue<'i>

Source

pub fn parse(input: &'i str) -> Result<Spanned<DeValue<'i>>, Error>

Parse a TOML value

Source

pub fn parse_recoverable(input: &'i str) -> (Spanned<DeValue<'i>>, Vec<Error>)

Parse a TOML value, with best effort recovery on error

Source

pub fn make_owned(&mut self)

Ensure no data is borrowed

Source

pub fn get<I>(&self, index: I) -> Option<&Spanned<DeValue<'i>>>
where I: Index,

Index into a TOML array or map. A string index can be used to access a value in a map, and a usize index can be used to access an element of an array.

Returns None if the type of self does not match the type of the index, for example if the index is a string and self is an array or a number. Also returns None if the given key does not exist in the map or the given index is not within the bounds of the array.

Source

pub fn as_integer(&self) -> Option<&DeInteger<'i>>

Extracts the integer value if it is an integer.

Source

pub fn is_integer(&self) -> bool

Tests whether this value is an integer.

Source

pub fn as_float(&self) -> Option<&DeFloat<'i>>

Extracts the float value if it is a float.

Source

pub fn is_float(&self) -> bool

Tests whether this value is a float.

Source

pub fn as_bool(&self) -> Option<bool>

Extracts the boolean value if it is a boolean.

Source

pub fn is_bool(&self) -> bool

Tests whether this value is a boolean.

Source

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

Extracts the string of this value if it is a string.

Source

pub fn is_str(&self) -> bool

Tests if this value is a string.

Source

pub fn as_datetime(&self) -> Option<&Datetime>

Extracts the datetime value if it is a datetime.

Note that a parsed TOML value will only contain ISO 8601 dates. An example date is:

1979-05-27T07:32:00Z
Source

pub fn is_datetime(&self) -> bool

Tests whether this value is a datetime.

Source

pub fn as_array(&self) -> Option<&DeArray<'i>>

Extracts the array value if it is an array.

Source

pub fn is_array(&self) -> bool

Tests whether this value is an array.

Source

pub fn as_table( &self, ) -> Option<&Map<Spanned<Cow<'i, str>>, Spanned<DeValue<'i>>>>

Extracts the table value if it is a table.

Source

pub fn is_table(&self) -> bool

Tests whether this value is a table.

Source

pub fn same_type(&self, other: &DeValue<'_>) -> bool

Tests whether this and another value have the same type.

Source

pub fn type_str(&self) -> &'static str

Returns a human-readable representation of the type of this value.

Trait Implementations§

Source§

impl<'i> Clone for DeValue<'i>

Source§

fn clone(&self) -> DeValue<'i>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'i> Debug for DeValue<'i>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<I> Index<I> for DeValue<'_>
where I: Index,

Source§

type Output = Spanned<DeValue<'_>>

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Spanned<DeValue<'_>>

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'i> Freeze for DeValue<'i>

§

impl<'i> RefUnwindSafe for DeValue<'i>

§

impl<'i> Send for DeValue<'i>

§

impl<'i> Sync for DeValue<'i>

§

impl<'i> Unpin for DeValue<'i>

§

impl<'i> UnwindSafe for DeValue<'i>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> QuickClone<T> for T
where T: Clone,

Source§

fn C(&self) -> T

Source§

impl<T> QuickToOwned for T
where T: ToOwned,

Source§

type Owned = <T as ToOwned>::Owned

Source§

fn O(&self) -> <T as QuickToOwned>::Owned

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,