Skip to main content

Value

Struct Value 

Source
pub struct Value<'a> { /* private fields */ }
Expand description

One value in a tree.

Implementations§

Source§

impl<'a> Value<'a>

Source

pub fn tag(&self) -> Option<&'a Tag>

The value’s YAML tag, which in ASDF is what gives it its type.

Source

pub fn has_tag(&self, name: &str) -> bool

Whether the tag names this ASDF schema, ignoring its version.

So has_tag("core/ndarray") matches both core/ndarray-1.0.0 and core/ndarray-1.1.0.

Source

pub fn as_raw_str(&self) -> Option<&'a str>

The raw scalar text, whatever its type.

Source

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

The value as a string, if it is one.

A quoted "42" is a string; an unquoted 42 is not.

Source

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

The value as a signed integer.

Source

pub fn as_u64(&self) -> Option<u64>

The value as an unsigned integer.

Source

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

The value as a float. Integers convert.

Source

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

The value as a boolean.

Source

pub fn is_null(&self) -> bool

Whether the value is null.

Source

pub fn is_mapping(&self) -> bool

Whether this is a mapping.

Source

pub fn is_sequence(&self) -> bool

Whether this is a sequence.

Source

pub fn len(&self) -> Option<usize>

The number of children, for a mapping or sequence.

Source

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

Whether this container has no children.

Source

pub fn get(&self, key: &str) -> Option<Value<'a>>

A mapping entry by key.

Source

pub fn at(&self, index: i64) -> Option<Value<'a>>

A sequence element, with negative indices counting from the end.

Source

pub fn path(&self, path: &str) -> Option<Value<'a>>

A value further down, by path.

Source

pub fn entries(&self) -> impl Iterator<Item = (&'a str, Value<'a>)> + 'a

Iterate a mapping’s entries in document order.

Source

pub fn items(&self) -> impl Iterator<Item = Value<'a>> + 'a

Iterate a sequence’s items.

Source

pub fn as_ndarray(&self) -> Option<Ndarray>

Interpret this value as an ndarray.

Returns None when it is not one; the array’s data is then read through AsdfFile::read_array.

Source

pub fn as_software(&self) -> Option<Software>

Interpret this value as a core/software record.

Source

pub fn as_history_entry(&self) -> Option<HistoryEntry>

Interpret this value as a core/history_entry record.

Source

pub fn as_extension_metadata(&self) -> Option<ExtensionMetadata>

Interpret this value as a core/extension_metadata record.

Source

pub fn as_time(&self) -> Option<Time>

Interpret this value as a time/time.

The schema allows the whole value to be the time string, or a mapping with value, format, scale and a location; both read here, and the calendar breakdown comes with it where the value allows one.

Source

pub fn is_alias(&self) -> bool

Whether this value is an alias to another node.

Trait Implementations§

Source§

impl<'a> Clone for Value<'a>

Source§

fn clone(&self) -> Self

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<'a> Copy for Value<'a>

Source§

impl<'a> Debug for Value<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Value<'a>

§

impl<'a> RefUnwindSafe for Value<'a>

§

impl<'a> Send for Value<'a>

§

impl<'a> Sync for Value<'a>

§

impl<'a> Unpin for Value<'a>

§

impl<'a> UnsafeUnpin for Value<'a>

§

impl<'a> UnwindSafe for Value<'a>

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<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<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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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