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
impl FillValueMetadataV3
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Returns true if the value is a null. Returns false otherwise.
Examples found in repository?
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 }Sourcepub fn as_null(&self) -> Option<()>
pub fn as_null(&self) -> Option<()>
If the value is a Null, returns (). Returns None otherwise.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
If the value is a string, returns the associated str. Returns None otherwise.
Sourcepub fn as_bytes(&self) -> Option<Vec<u8>>
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?
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 }Sourcepub fn as_array(&self) -> Option<&[FillValueMetadataV3]>
pub fn as_array(&self) -> Option<&[FillValueMetadataV3]>
If the value is an array, returns the associated elements. Returns None otherwise.
Sourcepub fn as_f32(&self) -> Option<f32>
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?
More examples
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 }Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Examples found in repository?
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
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 }Sourcepub fn as_custom<T>(&self) -> Option<T>where
T: DeserializeOwned,
pub fn as_custom<T>(&self) -> Option<T>where
T: DeserializeOwned,
Convert fill value metadata to a custom structure.
Trait Implementations§
Source§impl Clone for FillValueMetadataV3
impl Clone for FillValueMetadataV3
Source§fn clone(&self) -> FillValueMetadataV3
fn clone(&self) -> FillValueMetadataV3
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FillValueMetadataV3
impl Debug for FillValueMetadataV3
Source§impl<'de> Deserialize<'de> for FillValueMetadataV3
impl<'de> Deserialize<'de> for FillValueMetadataV3
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FillValueMetadataV3, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FillValueMetadataV3, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for FillValueMetadataV3
impl Display for FillValueMetadataV3
Source§impl From<&[u8]> for FillValueMetadataV3
impl From<&[u8]> for FillValueMetadataV3
Source§fn from(value: &[u8]) -> FillValueMetadataV3
fn from(value: &[u8]) -> FillValueMetadataV3
Source§impl From<&str> for FillValueMetadataV3
impl From<&str> for FillValueMetadataV3
Source§fn from(value: &str) -> FillValueMetadataV3
fn from(value: &str) -> FillValueMetadataV3
Source§impl<const N: usize> From<[FillValueMetadataV3; N]> for FillValueMetadataV3
impl<const N: usize> From<[FillValueMetadataV3; N]> for FillValueMetadataV3
Source§fn from(value: [FillValueMetadataV3; N]) -> FillValueMetadataV3
fn from(value: [FillValueMetadataV3; N]) -> FillValueMetadataV3
Source§impl From<FillValueMetadataV3> for ArrayBuilderFillValue
impl From<FillValueMetadataV3> for ArrayBuilderFillValue
Source§fn from(value: FillValueMetadata) -> Self
fn from(value: FillValueMetadata) -> Self
Source§impl From<HashMap<String, FillValueMetadataV3>> for FillValueMetadataV3
impl From<HashMap<String, FillValueMetadataV3>> for FillValueMetadataV3
Source§fn from(value: HashMap<String, FillValueMetadataV3>) -> FillValueMetadataV3
fn from(value: HashMap<String, FillValueMetadataV3>) -> FillValueMetadataV3
Source§impl From<Number> for FillValueMetadataV3
impl From<Number> for FillValueMetadataV3
Source§fn from(value: Number) -> FillValueMetadataV3
fn from(value: Number) -> FillValueMetadataV3
Source§impl From<String> for FillValueMetadataV3
impl From<String> for FillValueMetadataV3
Source§fn from(value: String) -> FillValueMetadataV3
fn from(value: String) -> FillValueMetadataV3
Source§impl From<Vec<FillValueMetadataV3>> for FillValueMetadataV3
impl From<Vec<FillValueMetadataV3>> for FillValueMetadataV3
Source§fn from(value: Vec<FillValueMetadataV3>) -> FillValueMetadataV3
fn from(value: Vec<FillValueMetadataV3>) -> FillValueMetadataV3
Source§impl From<bf16> for FillValueMetadataV3
impl From<bf16> for FillValueMetadataV3
Source§fn from(value: bf16) -> FillValueMetadataV3
fn from(value: bf16) -> FillValueMetadataV3
Source§impl From<bool> for FillValueMetadataV3
impl From<bool> for FillValueMetadataV3
Source§fn from(value: bool) -> FillValueMetadataV3
fn from(value: bool) -> FillValueMetadataV3
Source§impl From<f16> for FillValueMetadataV3
impl From<f16> for FillValueMetadataV3
Source§fn from(value: f16) -> FillValueMetadataV3
fn from(value: f16) -> FillValueMetadataV3
Source§impl From<f32> for FillValueMetadataV3
impl From<f32> for FillValueMetadataV3
Source§fn from(value: f32) -> FillValueMetadataV3
fn from(value: f32) -> FillValueMetadataV3
Source§impl From<f64> for FillValueMetadataV3
impl From<f64> for FillValueMetadataV3
Source§fn from(value: f64) -> FillValueMetadataV3
fn from(value: f64) -> FillValueMetadataV3
Source§impl From<i16> for FillValueMetadataV3
impl From<i16> for FillValueMetadataV3
Source§fn from(value: i16) -> FillValueMetadataV3
fn from(value: i16) -> FillValueMetadataV3
Source§impl From<i32> for FillValueMetadataV3
impl From<i32> for FillValueMetadataV3
Source§fn from(value: i32) -> FillValueMetadataV3
fn from(value: i32) -> FillValueMetadataV3
Source§impl From<i64> for FillValueMetadataV3
impl From<i64> for FillValueMetadataV3
Source§fn from(value: i64) -> FillValueMetadataV3
fn from(value: i64) -> FillValueMetadataV3
Source§impl From<i8> for FillValueMetadataV3
impl From<i8> for FillValueMetadataV3
Source§fn from(value: i8) -> FillValueMetadataV3
fn from(value: i8) -> FillValueMetadataV3
Source§impl From<u16> for FillValueMetadataV3
impl From<u16> for FillValueMetadataV3
Source§fn from(value: u16) -> FillValueMetadataV3
fn from(value: u16) -> FillValueMetadataV3
Source§impl From<u32> for FillValueMetadataV3
impl From<u32> for FillValueMetadataV3
Source§fn from(value: u32) -> FillValueMetadataV3
fn from(value: u32) -> FillValueMetadataV3
Source§impl From<u64> for FillValueMetadataV3
impl From<u64> for FillValueMetadataV3
Source§fn from(value: u64) -> FillValueMetadataV3
fn from(value: u64) -> FillValueMetadataV3
Source§impl From<u8> for FillValueMetadataV3
impl From<u8> for FillValueMetadataV3
Source§fn from(value: u8) -> FillValueMetadataV3
fn from(value: u8) -> FillValueMetadataV3
Source§impl PartialEq for FillValueMetadataV3
impl PartialEq for FillValueMetadataV3
Source§impl Serialize for FillValueMetadataV3
impl Serialize for FillValueMetadataV3
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for FillValueMetadataV3
impl StructuralPartialEq for FillValueMetadataV3
Auto Trait Implementations§
impl Freeze for FillValueMetadataV3
impl Send for FillValueMetadataV3
impl Sync for FillValueMetadataV3
impl RefUnwindSafe for FillValueMetadataV3
impl Unpin for FillValueMetadataV3
impl UnsafeUnpin for FillValueMetadataV3
impl UnwindSafe for FillValueMetadataV3
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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