Skip to main content

FillValueMetadata

Enum FillValueMetadata 

Source
pub enum FillValueMetadata {
    Null,
    Bool(bool),
    Number(Number),
    String(String),
    Array(Vec<FillValueMetadataV3>),
    Object(HashMap<String, FillValueMetadataV3>),
}
Expand description

Zarr V3 fill value metadata.

Variants§

§

Null

Represents a JSON null value.

§

Bool(bool)

Represents a JSON boolean.

§

Number(Number)

Represents a finite JSON number, whether integer or floating point.

§

String(String)

Represents a JSON string. This includes hex strings and non-finite float representations.

§

Array(Vec<FillValueMetadataV3>)

Represents a JSON array.

§

Object(HashMap<String, FillValueMetadataV3>)

Represents a JSON object.

Implementations§

Source§

impl FillValueMetadataV3

Source

pub fn is_null(&self) -> bool

Returns true if the value is a null. Returns false otherwise.

Examples found in repository?
examples/custom_data_type_variable_size.rs (line 124)
117    fn fill_value(
118        &self,
119        fill_value_metadata: &FillValueMetadata,
120        _version: ZarrVersion,
121    ) -> Result<FillValue, DataTypeFillValueMetadataError> {
122        if let Some(f) = fill_value_metadata.as_f32() {
123            Ok(FillValue::new(f.to_ne_bytes().to_vec()))
124        } else if fill_value_metadata.is_null() {
125            Ok(FillValue::new(vec![]))
126        } else if let Some(bytes) = fill_value_metadata.as_bytes() {
127            Ok(FillValue::new(bytes))
128        } else {
129            Err(DataTypeFillValueMetadataError)
130        }
131    }
Source

pub fn as_null(&self) -> Option<()>

If the value is a Null, returns (). Returns None otherwise.

Source

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

If the value is a string, returns the associated str. Returns None otherwise.

Source

pub fn as_bytes(&self) -> Option<Vec<u8>>

Returns a vector of bytes if the value is an array of integers in [0, 255].

Examples found in repository?
examples/custom_data_type_variable_size.rs (line 126)
117    fn fill_value(
118        &self,
119        fill_value_metadata: &FillValueMetadata,
120        _version: ZarrVersion,
121    ) -> Result<FillValue, DataTypeFillValueMetadataError> {
122        if let Some(f) = fill_value_metadata.as_f32() {
123            Ok(FillValue::new(f.to_ne_bytes().to_vec()))
124        } else if fill_value_metadata.is_null() {
125            Ok(FillValue::new(vec![]))
126        } else if let Some(bytes) = fill_value_metadata.as_bytes() {
127            Ok(FillValue::new(bytes))
128        } else {
129            Err(DataTypeFillValueMetadataError)
130        }
131    }
Source

pub fn as_array(&self) -> Option<&[FillValueMetadataV3]>

If the value is an array, returns the associated elements. Returns None otherwise.

Source

pub fn as_object(&self) -> Option<HashMap<String, FillValueMetadataV3>>

If the value is an object, returns the associated HashMap. Returns None otherwise.

Source

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

If the value is a Boolean, returns the associated bool. Returns None otherwise.

Source

pub fn as_bf16(&self) -> Option<bf16>

If the value is a number or non-finite float representation, represent it as bf16 if possible. Returns None otherwise.

Source

pub fn as_f16(&self) -> Option<f16>

If the value is a number or non-finite float representation, represent it as f16 if possible. Returns None otherwise.

Source

pub fn as_f32(&self) -> Option<f32>

If the value is a number or non-finite float representation, represent it as f32 if possible. Returns None otherwise.

Examples found in repository?
examples/custom_data_type_float8_e3m4.rs (line 60)
54    fn fill_value(
55        &self,
56        fill_value_metadata: &FillValueMetadata,
57        _version: ZarrVersion,
58    ) -> Result<FillValue, DataTypeFillValueMetadataError> {
59        let element_metadata: f32 = fill_value_metadata
60            .as_f32()
61            .ok_or(DataTypeFillValueMetadataError)?;
62        let element = CustomDataTypeFloat8e3m4Element::from(element_metadata);
63        Ok(FillValue::new(element.into_ne_bytes().to_vec()))
64    }
More examples
Hide additional examples
examples/custom_data_type_variable_size.rs (line 122)
117    fn fill_value(
118        &self,
119        fill_value_metadata: &FillValueMetadata,
120        _version: ZarrVersion,
121    ) -> Result<FillValue, DataTypeFillValueMetadataError> {
122        if let Some(f) = fill_value_metadata.as_f32() {
123            Ok(FillValue::new(f.to_ne_bytes().to_vec()))
124        } else if fill_value_metadata.is_null() {
125            Ok(FillValue::new(vec![]))
126        } else if let Some(bytes) = fill_value_metadata.as_bytes() {
127            Ok(FillValue::new(bytes))
128        } else {
129            Err(DataTypeFillValueMetadataError)
130        }
131    }
Source

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

If the value is a number or non-finite float representation, represent it as f64 if possible. Returns None otherwise.

Source

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

If the value is an integer, represent it as u64 if possible. Returns None otherwise.

Examples found in repository?
examples/custom_data_type_uint4.rs (line 61)
55    fn fill_value(
56        &self,
57        fill_value_metadata: &FillValueMetadata,
58        _version: ZarrVersion,
59    ) -> Result<FillValue, DataTypeFillValueMetadataError> {
60        let element_metadata: u64 = fill_value_metadata
61            .as_u64()
62            .ok_or(DataTypeFillValueMetadataError)?;
63        let element = CustomDataTypeUInt4Element::try_from(element_metadata)
64            .map_err(|_| DataTypeFillValueMetadataError)?;
65        Ok(FillValue::new(element.into_ne_bytes().to_vec()))
66    }
More examples
Hide additional examples
examples/custom_data_type_uint12.rs (line 59)
53    fn fill_value(
54        &self,
55        fill_value_metadata: &FillValueMetadata,
56        _version: ZarrVersion,
57    ) -> Result<FillValue, DataTypeFillValueMetadataError> {
58        let element_metadata: u64 = fill_value_metadata
59            .as_u64()
60            .ok_or(DataTypeFillValueMetadataError)?;
61        let element = CustomDataTypeUInt12Element::try_from(element_metadata)
62            .map_err(|_| DataTypeFillValueMetadataError)?;
63        Ok(FillValue::new(element.into_le_bytes().to_vec()))
64    }
Source

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

If the value is an integer, represent it as i64 if possible. Returns None otherwise.

Source

pub fn as_custom<T>(&self) -> Option<T>

Convert fill value metadata to a custom structure.

Examples found in repository?
examples/custom_data_type_fixed_size.rs (line 187)
181    fn fill_value(
182        &self,
183        fill_value_metadata: &FillValueMetadata,
184        _version: ZarrVersion,
185    ) -> Result<FillValue, DataTypeFillValueMetadataError> {
186        let element_metadata: CustomDataTypeFixedSizeMetadata = fill_value_metadata
187            .as_custom()
188            .ok_or(DataTypeFillValueMetadataError)?;
189        Ok(FillValue::new(element_metadata.to_ne_bytes().to_vec()))
190    }

Trait Implementations§

Source§

impl Clone for FillValueMetadataV3

Source§

fn clone(&self) -> FillValueMetadataV3

Returns a duplicate 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 FillValueMetadataV3

Source§

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

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

impl<'de> Deserialize<'de> for FillValueMetadataV3

Source§

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

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

impl Display for FillValueMetadataV3

Source§

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

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

impl From<&[u8]> for FillValueMetadataV3

Source§

fn from(value: &[u8]) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<&str> for FillValueMetadataV3

Source§

fn from(value: &str) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl<const N: usize> From<[FillValueMetadataV3; N]> for FillValueMetadataV3

Source§

fn from(value: [FillValueMetadataV3; N]) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<FillValueMetadataV3> for ArrayBuilderFillValue

Source§

fn from(value: FillValueMetadata) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<String, FillValueMetadataV3>> for FillValueMetadataV3

Source§

fn from(value: HashMap<String, FillValueMetadataV3>) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<Number> for FillValueMetadataV3

Source§

fn from(value: Number) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<String> for FillValueMetadataV3

Source§

fn from(value: String) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<Vec<FillValueMetadataV3>> for FillValueMetadataV3

Source§

fn from(value: Vec<FillValueMetadataV3>) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for FillValueMetadataV3

Source§

fn from(value: Vec<u8>) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<bf16> for FillValueMetadataV3

Source§

fn from(value: bf16) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<bool> for FillValueMetadataV3

Source§

fn from(value: bool) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<f16> for FillValueMetadataV3

Source§

fn from(value: f16) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<f32> for FillValueMetadataV3

Source§

fn from(value: f32) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<f64> for FillValueMetadataV3

Source§

fn from(value: f64) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<i16> for FillValueMetadataV3

Source§

fn from(value: i16) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<i32> for FillValueMetadataV3

Source§

fn from(value: i32) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<i64> for FillValueMetadataV3

Source§

fn from(value: i64) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<i8> for FillValueMetadataV3

Source§

fn from(value: i8) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<u16> for FillValueMetadataV3

Source§

fn from(value: u16) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<u32> for FillValueMetadataV3

Source§

fn from(value: u32) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<u64> for FillValueMetadataV3

Source§

fn from(value: u64) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl From<u8> for FillValueMetadataV3

Source§

fn from(value: u8) -> FillValueMetadataV3

Converts to this type from the input type.
Source§

impl PartialEq for FillValueMetadataV3

Source§

fn eq(&self, other: &FillValueMetadataV3) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for FillValueMetadataV3

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for FillValueMetadataV3

Source§

impl StructuralPartialEq for FillValueMetadataV3

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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
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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,