#[non_exhaustive]#[repr(C)]pub enum Def {
Undefined,
Scalar,
Map(MapDef),
Set(SetDef),
List(ListDef),
Array(ArrayDef),
NdArray(NdArrayDef),
Slice(SliceDef),
Option(OptionDef),
Result(ResultDef),
Pointer(PointerDef),
DynamicValue(DynamicValueDef),
}Expand description
The semantic definition of a shape: is it more like a scalar, a map, a list?
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Undefined
Undefined - you can interact with the type through Type and VTableView.
Scalar
Scalar — those don’t have a def, they’re not composed of other things.
You can interact with them through VTableView.
e.g. u32, String, bool, SocketAddr, etc.
Map(MapDef)
Map — keys are dynamic (and strings, sorry), values are homogeneous
e.g. HashMap<String, T>
Set(SetDef)
Unique set of homogenous values
e.g. HashSet<T>
List(ListDef)
Ordered list of homogenous values, variable size
e.g. Vec<T>
Array(ArrayDef)
Fixed-size array of homogeneous values, fixed size
e.g. [T; 3]
NdArray(NdArrayDef)
n-dimensional array of homogeneous values, fixed size
e.g. Vector<T>, Matrix<T>, Tensor<T>
Slice(SliceDef)
Slice - a reference to a contiguous sequence of elements
e.g. [T]
Option(OptionDef)
Option
e.g. Option<T>
Result(ResultDef)
Result
e.g. Result<T, E>
Pointer(PointerDef)
Pointer types like Arc<T>, Rc<T>, etc.
DynamicValue(DynamicValueDef)
Dynamic value that can hold any type at runtime.
e.g. facet_value::Value, serde_json::Value
Implementations§
Source§impl Def
impl Def
Sourcepub const fn map_builder(
vtable: &'static MapVTable,
k: &'static Shape,
v: &'static Shape,
) -> DefMapBuilder
pub const fn map_builder( vtable: &'static MapVTable, k: &'static Shape, v: &'static Shape, ) -> DefMapBuilder
Sourcepub const fn set_builder(
vtable: &'static SetVTable,
t: &'static Shape,
) -> DefSetBuilder
pub const fn set_builder( vtable: &'static SetVTable, t: &'static Shape, ) -> DefSetBuilder
Sourcepub const fn list_builder(
vtable: &'static ListVTable,
t: &'static Shape,
) -> DefListBuilder
pub const fn list_builder( vtable: &'static ListVTable, t: &'static Shape, ) -> DefListBuilder
Sourcepub const fn array_builder(
vtable: &'static ArrayVTable,
t: &'static Shape,
n: usize,
) -> DefArrayBuilder
pub const fn array_builder( vtable: &'static ArrayVTable, t: &'static Shape, n: usize, ) -> DefArrayBuilder
Sourcepub const fn option_builder(
vtable: &'static OptionVTable,
t: &'static Shape,
) -> DefOptionBuilder
pub const fn option_builder( vtable: &'static OptionVTable, t: &'static Shape, ) -> DefOptionBuilder
Sourcepub const fn result_builder(
vtable: &'static ResultVTable,
t: &'static Shape,
e: &'static Shape,
) -> DefResultBuilder
pub const fn result_builder( vtable: &'static ResultVTable, t: &'static Shape, e: &'static Shape, ) -> DefResultBuilder
Sourcepub fn into_scalar(self) -> Result<(), Self>
pub fn into_scalar(self) -> Result<(), Self>
Returns the ScalarDef wrapped in an Ok if this is a Def::Scalar.
Sourcepub fn into_map(self) -> Result<MapDef, Self>
pub fn into_map(self) -> Result<MapDef, Self>
Returns the MapDef wrapped in an Ok if this is a Def::Map.
Sourcepub fn into_set(self) -> Result<SetDef, Self>
pub fn into_set(self) -> Result<SetDef, Self>
Returns the SetDef wrapped in an Ok if this is a Def::Set.
Sourcepub fn into_list(self) -> Result<ListDef, Self>
pub fn into_list(self) -> Result<ListDef, Self>
Returns the ListDef wrapped in an Ok if this is a Def::List.
Sourcepub fn into_array(self) -> Result<ArrayDef, Self>
pub fn into_array(self) -> Result<ArrayDef, Self>
Returns the ArrayDef wrapped in an Ok if this is a Def::Array.
Sourcepub fn into_ndarray(self) -> Result<NdArrayDef, Self>
pub fn into_ndarray(self) -> Result<NdArrayDef, Self>
Returns the NdArrayDef wrapped in an Ok if this is a Def::NdArray.
Sourcepub fn into_slice(self) -> Result<SliceDef, Self>
pub fn into_slice(self) -> Result<SliceDef, Self>
Returns the SliceDef wrapped in an Ok if this is a Def::Slice.
Sourcepub fn into_option(self) -> Result<OptionDef, Self>
pub fn into_option(self) -> Result<OptionDef, Self>
Returns the OptionDef wrapped in an Ok if this is a Def::Option.
Sourcepub fn into_result(self) -> Result<ResultDef, Self>
pub fn into_result(self) -> Result<ResultDef, Self>
Returns the ResultDef wrapped in an Ok if this is a Def::Result.
Sourcepub fn into_pointer(self) -> Result<PointerDef, Self>
pub fn into_pointer(self) -> Result<PointerDef, Self>
Returns the PointerDef wrapped in an Ok if this is a Def::Pointer.
Sourcepub fn into_dynamic_value(self) -> Result<DynamicValueDef, Self>
pub fn into_dynamic_value(self) -> Result<DynamicValueDef, Self>
Returns the DynamicValueDef wrapped in an Ok if this is a Def::DynamicValue.
Sourcepub const fn default_type(&self) -> Type
pub const fn default_type(&self) -> Type
Returns the default Type for this Def.
This is used by ShapeBuilder to infer the ty field from def.
For most Def variants, this returns Type::User(UserType::Opaque).
Array and Slice have corresponding Type::Sequence variants.