pub trait ArrayElement: Sealed + Copy {
const SCALAR: ScalarType;
// Required methods
fn to_bytes(self) -> Vec<u8> ⓘ;
fn from_element(element: &Element) -> Option<Self>;
}Expand description
A scalar type an array can be written from and read back as.
Implemented for the numeric types ASDF’s core/ndarray schema names, so
AsdfBuilder::set_array and AsdfFile::read_array_of work for any of
them without a method per type.
Sealed: the set of scalar types is the schema’s, not the caller’s.
Required Associated Constants§
Sourceconst SCALAR: ScalarType
const SCALAR: ScalarType
The schema’s name for this type.
Required Methods§
Sourcefn from_element(element: &Element) -> Option<Self>
fn from_element(element: &Element) -> Option<Self>
Read a decoded element as this type, or None if it is not one.
Narrowing that would lose the value is a None rather than a silent
truncation: a caller asking for Vec<i32> wants the numbers, not
whatever survives the cast.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".