#[non_exhaustive]#[repr(C)]pub enum Def {
Scalar(ScalarDef),
Struct(Struct),
Enum(EnumDef),
Map(MapDef),
List(ListDef),
Array(ArrayDef),
Slice(SliceDef),
Option(OptionDef),
SmartPointer(SmartPointerDef),
FunctionPointer(FunctionPointerDef),
}Expand description
The definition of a shape: is it more like a struct, a map, a list?
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Scalar(ScalarDef)
Scalar — those don’t have a def, they’re not composed of other things.
You can interact with them through ValueVTable.
e.g. u32, String, bool, SocketAddr, etc.
Struct(Struct)
Various kinds of structs, see StructKind
e.g. struct Struct { field: u32 }, struct TupleStruct(u32, u32);, (u32, u32)
Enum(EnumDef)
Enum with variants
e.g. enum Enum { Variant1, Variant2 }
Map(MapDef)
Map — keys are dynamic (and strings, sorry), values are homogeneous
e.g. Map<String, T>
List(ListDef)
Ordered list of heterogenous values, variable size
e.g. Vec<T>
Array(ArrayDef)
Fixed-size array of heterogenous values
e.g. [T; 32]
Slice(SliceDef)
Slice — a reference to a contiguous sequence of elements
e.g. &[T]
Option(OptionDef)
Option
e.g. Option<T>
SmartPointer(SmartPointerDef)
Smart pointers, like Arc<T>, Rc<T>, etc.
FunctionPointer(FunctionPointerDef)
Function pointers, like fn(u32) -> String, extern "C" fn() -> *const T, etc.
Implementations§
Source§impl Def
impl Def
Sourcepub fn into_scalar(self) -> Result<ScalarDef, Self>
pub fn into_scalar(self) -> Result<ScalarDef, Self>
Returns the ScalarDef wrapped in an Ok if this is a Def::Scalar.
Sourcepub fn into_struct(self) -> Result<Struct, Self>
pub fn into_struct(self) -> Result<Struct, Self>
Returns the Struct wrapped in an Ok if this is a Def::Struct.
Sourcepub fn into_enum(self) -> Result<EnumDef, Self>
pub fn into_enum(self) -> Result<EnumDef, Self>
Returns the EnumDef wrapped in an Ok if this is a Def::Enum.
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_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_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_smart_pointer(self) -> Result<SmartPointerDef, Self>
pub fn into_smart_pointer(self) -> Result<SmartPointerDef, Self>
Returns the SmartPointerDef wrapped in an Ok if this is a Def::SmartPointer.