Enum Value

Source
pub enum Value {
Show 16 variants Nullable(Option<Box<Value>>), Boolean(bool), I32(i32), I64(i64), U32(u32), U64(u64), F32(f32), F64(f64), Bytes(Arc<Vec<u8>>), String(Arc<String>), StaticArray(Vec<Value>), DynamicArray(Vec<Value>), Map(ValueMap), AssetRef(AssetId), Record(ValueRecord), Enum(ValueEnum),
}
Expand description

All the possible types that can be stored in a Value

Variants§

§

Nullable(Option<Box<Value>>)

§

Boolean(bool)

§

I32(i32)

§

I64(i64)

§

U32(u32)

§

U64(u64)

§

F32(f32)

§

F64(f64)

§

Bytes(Arc<Vec<u8>>)

§

String(Arc<String>)

§

StaticArray(Vec<Value>)

§

DynamicArray(Vec<Value>)

§

Map(ValueMap)

§

AssetRef(AssetId)

§

Record(ValueRecord)

§

Enum(ValueEnum)

Implementations§

Source§

impl Value

Source

pub fn default_for_schema<'a>( schema: &Schema, schema_set: &'a SchemaSet, ) -> &'a Value

Produces a default value for the given schema. Because schemas may reference other schemas, and a default value may have containers in it, we need to have access to all schemas that may exist.

Source

pub fn matches_schema( &self, schema: &Schema, named_types: &HashMap<SchemaFingerprint, SchemaNamedType, RandomState>, ) -> bool

Validates that the value matches the provided schema exactly. Even if this returns false, it may still be possible to migrate the data into the given schema. This will recursively descend through containers, records, etc.

Source

pub fn as_property_value(&self) -> Option<PropertyValue>

Returns the value as a property value, if possible. Some types cannot be stored as PropertyValue

Source

pub fn is_nullable(&self) -> bool

Source

pub fn is_null(&self) -> bool

Source

pub fn as_nullable(&self) -> Result<Option<&Value>, DataSetErrorWithBacktrace>

Source

pub fn try_as_nullable(&self) -> Option<Option<&Value>>

Source

pub fn set_nullable(&mut self, value: Option<Value>)

Source

pub fn is_boolean(&self) -> bool

Source

pub fn as_boolean(&self) -> Result<bool, DataSetErrorWithBacktrace>

Source

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

Source

pub fn set_boolean(&mut self, value: bool)

Source

pub fn is_i32(&self) -> bool

Source

pub fn as_i32(&self) -> Result<i32, DataSetErrorWithBacktrace>

Source

pub fn try_as_i32(&self) -> Option<i32>

Source

pub fn set_i32(&mut self, value: i32)

Source

pub fn is_u32(&self) -> bool

Source

pub fn as_u32(&self) -> Result<u32, DataSetErrorWithBacktrace>

Source

pub fn try_as_u32(&self) -> Option<u32>

Source

pub fn set_u32(&mut self, value: u32)

Source

pub fn is_i64(&self) -> bool

Source

pub fn as_i64(&self) -> Result<i64, DataSetErrorWithBacktrace>

Source

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

Source

pub fn set_i64(&mut self, value: i64)

Source

pub fn is_u64(&self) -> bool

Source

pub fn as_u64(&self) -> Result<u64, DataSetErrorWithBacktrace>

Source

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

Source

pub fn set_u64(&mut self, value: u64)

Source

pub fn is_f32(&self) -> bool

Source

pub fn as_f32(&self) -> Result<f32, DataSetErrorWithBacktrace>

Source

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

Source

pub fn set_f32(&mut self, value: f32)

Source

pub fn is_f64(&self) -> bool

Source

pub fn as_f64(&self) -> Result<f64, DataSetErrorWithBacktrace>

Source

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

Source

pub fn set_f64(&mut self, value: f64)

Source

pub fn is_bytes(&self) -> bool

Source

pub fn as_bytes(&self) -> Result<&Arc<Vec<u8>>, DataSetErrorWithBacktrace>

Source

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

Source

pub fn set_bytes(&mut self, value: Arc<Vec<u8>>)

Source

pub fn is_string(&self) -> bool

Source

pub fn as_string(&self) -> Result<&Arc<String>, DataSetErrorWithBacktrace>

Source

pub fn try_as_string(&self) -> Option<&Arc<String>>

Source

pub fn set_string(&mut self, value: Arc<String>)

Source

pub fn is_asset_ref(&self) -> bool

Source

pub fn as_asset_ref(&self) -> Result<AssetId, DataSetErrorWithBacktrace>

Source

pub fn try_as_asset_ref(&self) -> Option<AssetId>

Source

pub fn set_asset_ref(&mut self, value: AssetId)

Source

pub fn is_record(&self) -> bool

Source

pub fn as_record(&self) -> Result<&ValueRecord, DataSetErrorWithBacktrace>

Source

pub fn try_as_record(&self) -> Option<&ValueRecord>

Source

pub fn set_record(&mut self, value: ValueRecord)

Source

pub fn is_enum(&self) -> bool

Source

pub fn as_enum(&self) -> Result<&ValueEnum, DataSetErrorWithBacktrace>

Source

pub fn try_as_enum(&self) -> Option<&ValueEnum>

Source

pub fn set_enum(&mut self, value: ValueEnum)

Source

pub fn enum_value_from_string( schema_enum: &SchemaEnum, name: &str, ) -> Option<Value>

Utility function to convert a string to an enum value. This handles potentially matching a symbol alias and using the new symbol name instead. We generally expect an enum values in memory to use the current symbol name, not an alias

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

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 Value

Source§

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

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

impl Hash for Value

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

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> CallHasher for T
where T: Hash + ?Sized,

Source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

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