#[non_exhaustive]pub enum Value {
Null,
Bool(bool),
Int(i64),
Float(f64),
Text(String),
Bytes(Bytes),
List(Vec<Value>),
Map(Fields),
Tensor(Tensor),
Image(Arc<DynamicImage>),
Custom(Arc<dyn CustomValue>),
}Expand description
A value carried by a sample field.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Null
Absent or JSON null.
Bool(bool)
A boolean.
Int(i64)
An integer, e.g. the contents of a .cls file.
Float(f64)
A floating point number.
Text(String)
Text, e.g. the contents of a .txt file.
Bytes(Bytes)
Undecoded (or deliberately raw) file contents.
List(Vec<Value>)
An ordered sequence, e.g. a JSON array or a collated batch column.
Map(Fields)
A string-keyed mapping, e.g. a JSON object or an .npz archive.
Tensor(Tensor)
A dense numeric array, e.g. from .npy or .ten.
Image(Arc<DynamicImage>)
Available on crate feature
image only.A decoded image.
Custom(Arc<dyn CustomValue>)
Anything else a user-supplied decoder produced.
Implementations§
Source§impl Value
impl Value
Sourcepub fn custom<T: CustomValue>(value: T) -> Value
pub fn custom<T: CustomValue>(value: T) -> Value
Wrap an arbitrary value so it can live inside a sample.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Read this value as an integer, accepting Int, Bool and whole Floats.
Sourcepub fn as_image(&self) -> Option<&DynamicImage>
Available on crate feature image only.
pub fn as_image(&self) -> Option<&DynamicImage>
image only.Borrow the decoded image, if this value is one.
Sourcepub fn downcast_ref<T: Any>(&self) -> Option<&T>
pub fn downcast_ref<T: Any>(&self) -> Option<&T>
Downcast a Value::Custom to a concrete type.
Sourcepub fn expect_bytes(&self, key: &str) -> Result<&Bytes>
pub fn expect_bytes(&self, key: &str) -> Result<&Bytes>
Like Value::as_bytes but produces a descriptive error.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Value
impl !RefUnwindSafe for Value
impl !UnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CustomValue for T
impl<T> CustomValue for T
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> ⓘ
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 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> ⓘ
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