pub enum Value {
}
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
impl Value
Sourcepub fn default_for_schema<'a>(
schema: &Schema,
schema_set: &'a SchemaSet,
) -> &'a Value
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.
Sourcepub fn matches_schema(
&self,
schema: &Schema,
named_types: &HashMap<SchemaFingerprint, SchemaNamedType, RandomState>,
) -> bool
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.
Sourcepub fn as_property_value(&self) -> Option<PropertyValue>
pub fn as_property_value(&self) -> Option<PropertyValue>
Returns the value as a property value, if possible. Some types cannot be stored as PropertyValue
pub fn is_nullable(&self) -> bool
pub fn is_null(&self) -> bool
pub fn as_nullable(&self) -> Result<Option<&Value>, DataSetErrorWithBacktrace>
pub fn try_as_nullable(&self) -> Option<Option<&Value>>
pub fn set_nullable(&mut self, value: Option<Value>)
pub fn is_boolean(&self) -> bool
pub fn as_boolean(&self) -> Result<bool, DataSetErrorWithBacktrace>
pub fn try_as_boolean(&self) -> Option<bool>
pub fn set_boolean(&mut self, value: bool)
pub fn is_i32(&self) -> bool
pub fn as_i32(&self) -> Result<i32, DataSetErrorWithBacktrace>
pub fn try_as_i32(&self) -> Option<i32>
pub fn set_i32(&mut self, value: i32)
pub fn is_u32(&self) -> bool
pub fn as_u32(&self) -> Result<u32, DataSetErrorWithBacktrace>
pub fn try_as_u32(&self) -> Option<u32>
pub fn set_u32(&mut self, value: u32)
pub fn is_i64(&self) -> bool
pub fn as_i64(&self) -> Result<i64, DataSetErrorWithBacktrace>
pub fn try_as_i64(&self) -> Option<i64>
pub fn set_i64(&mut self, value: i64)
pub fn is_u64(&self) -> bool
pub fn as_u64(&self) -> Result<u64, DataSetErrorWithBacktrace>
pub fn try_as_u64(&self) -> Option<u64>
pub fn set_u64(&mut self, value: u64)
pub fn is_f32(&self) -> bool
pub fn as_f32(&self) -> Result<f32, DataSetErrorWithBacktrace>
pub fn try_as_f32(&self) -> Option<f32>
pub fn set_f32(&mut self, value: f32)
pub fn is_f64(&self) -> bool
pub fn as_f64(&self) -> Result<f64, DataSetErrorWithBacktrace>
pub fn try_as_f64(&self) -> Option<f64>
pub fn set_f64(&mut self, value: f64)
pub fn is_bytes(&self) -> bool
pub fn as_bytes(&self) -> Result<&Arc<Vec<u8>>, DataSetErrorWithBacktrace>
pub fn try_as_bytes(&self) -> Option<&Arc<Vec<u8>>>
pub fn set_bytes(&mut self, value: Arc<Vec<u8>>)
pub fn is_string(&self) -> bool
pub fn as_string(&self) -> Result<&Arc<String>, DataSetErrorWithBacktrace>
pub fn try_as_string(&self) -> Option<&Arc<String>>
pub fn set_string(&mut self, value: Arc<String>)
pub fn is_asset_ref(&self) -> bool
pub fn as_asset_ref(&self) -> Result<AssetId, DataSetErrorWithBacktrace>
pub fn try_as_asset_ref(&self) -> Option<AssetId>
pub fn set_asset_ref(&mut self, value: AssetId)
pub fn is_record(&self) -> bool
pub fn as_record(&self) -> Result<&ValueRecord, DataSetErrorWithBacktrace>
pub fn try_as_record(&self) -> Option<&ValueRecord>
pub fn set_record(&mut self, value: ValueRecord)
pub fn is_enum(&self) -> bool
pub fn as_enum(&self) -> Result<&ValueEnum, DataSetErrorWithBacktrace>
pub fn try_as_enum(&self) -> Option<&ValueEnum>
pub fn set_enum(&mut self, value: ValueEnum)
Sourcepub fn enum_value_from_string(
schema_enum: &SchemaEnum,
name: &str,
) -> Option<Value>
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