Struct kumo_api_types::shaping::HashableTomlValue

source ·
pub struct HashableTomlValue { /* private fields */ }
Expand description

toml::Value is not Hash because it may contain floating point numbers, which are problematic from a Ord and Eq perspective. We’re okay with skirting around that for our purposes here, so we implement our own hashable wrapper around the toml value.

Methods from Deref<Target = Value>§

pub fn get<I>(&self, index: I) -> Option<&Value>
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.

pub fn as_integer(&self) -> Option<i64>

Extracts the integer value if it is an integer.

pub fn is_integer(&self) -> bool

Tests whether this value is an integer.

pub fn as_float(&self) -> Option<f64>

Extracts the float value if it is a float.

pub fn is_float(&self) -> bool

Tests whether this value is a float.

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

Extracts the boolean value if it is a boolean.

pub fn is_bool(&self) -> bool

Tests whether this value is a boolean.

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

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

pub fn is_str(&self) -> bool

Tests if this value is a string.

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

pub fn is_datetime(&self) -> bool

Tests whether this value is a datetime.

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

Extracts the array value if it is an array.

pub fn is_array(&self) -> bool

Tests whether this value is an array.

pub fn as_table(&self) -> Option<&Map<String, Value>>

Extracts the table value if it is a table.

pub fn is_table(&self) -> bool

Tests whether this value is a table.

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

Tests whether this and another value have the same type.

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

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

Trait Implementations§

source§

impl Clone for HashableTomlValue

source§

fn clone(&self) -> HashableTomlValue

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 Debug for HashableTomlValue

source§

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

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

impl Deref for HashableTomlValue

§

type Target = Value

The resulting type after dereferencing.
source§

fn deref(&self) -> &Value

Dereferences the value.
source§

impl<'de> Deserialize<'de> for HashableTomlValue

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl From<HashableTomlValue> for Value

source§

fn from(value: HashableTomlValue) -> Value

Converts to this type from the input type.
source§

impl From<Value> for HashableTomlValue

source§

fn from(value: Value) -> Self

Converts to this type from the input type.
source§

impl Hash for HashableTomlValue

source§

fn hash<H>(&self, h: &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 Serialize for HashableTomlValue

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

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

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

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

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

source§

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

§

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

§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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