Enum Def

Source
#[non_exhaustive]
#[repr(C)]
pub enum Def<'shape> { Undefined, Scalar(ScalarDef<'shape>), Map(MapDef<'shape>), Set(SetDef<'shape>), List(ListDef<'shape>), Array(ArrayDef<'shape>), Slice(SliceDef<'shape>), Option(OptionDef<'shape>), SmartPointer(SmartPointerDef<'shape>), }
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
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.
§

Undefined

Undefined - you can interact with the type through Type and ValueVTable.

§

Scalar(ScalarDef<'shape>)

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.

§

Map(MapDef<'shape>)

Map — keys are dynamic (and strings, sorry), values are homogeneous

e.g. HashMap<String, T>

§

Set(SetDef<'shape>)

Unique set of homogenous values

e.g. HashSet<T>

§

List(ListDef<'shape>)

Ordered list of heterogenous values, variable size

e.g. Vec<T>

§

Array(ArrayDef<'shape>)

Fixed-size array of heterogeneous values, fixed size

e.g. [T; 3]

§

Slice(SliceDef<'shape>)

Slice - a reference to a contiguous sequence of elements

e.g. [T]

§

Option(OptionDef<'shape>)

Option

e.g. Option<T>

§

SmartPointer(SmartPointerDef<'shape>)

Smart pointers, like Arc<T>, Rc<T>, etc.

Implementations§

Source§

impl<'shape> Def<'shape>

Source

pub fn into_scalar(self) -> Result<ScalarDef<'shape>, Self>

Returns the ScalarDef wrapped in an Ok if this is a Def::Scalar.

Source

pub fn into_map(self) -> Result<MapDef<'shape>, Self>

Returns the MapDef wrapped in an Ok if this is a Def::Map.

Source

pub fn into_set(self) -> Result<SetDef<'shape>, Self>

Returns the SetDef wrapped in an Ok if this is a Def::Set.

Source

pub fn into_list(self) -> Result<ListDef<'shape>, Self>

Returns the ListDef wrapped in an Ok if this is a Def::List.

Source

pub fn into_array(self) -> Result<ArrayDef<'shape>, Self>

Returns the ArrayDef wrapped in an Ok if this is a Def::Array.

Source

pub fn into_slice(self) -> Result<SliceDef<'shape>, Self>

Returns the SliceDef wrapped in an Ok if this is a Def::Slice.

Source

pub fn into_option(self) -> Result<OptionDef<'shape>, Self>

Returns the OptionDef wrapped in an Ok if this is a Def::Option.

Source

pub fn into_smart_pointer(self) -> Result<SmartPointerDef<'shape>, Self>

Returns the SmartPointerDef wrapped in an Ok if this is a Def::SmartPointer.

Trait Implementations§

Source§

impl<'shape> Clone for Def<'shape>

Source§

fn clone(&self) -> Def<'shape>

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<'shape> Debug for Def<'shape>

Source§

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

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

impl<'shape> Copy for Def<'shape>

Auto Trait Implementations§

§

impl<'shape> Freeze for Def<'shape>

§

impl<'shape> RefUnwindSafe for Def<'shape>

§

impl<'shape> Send for Def<'shape>

§

impl<'shape> Sync for Def<'shape>

§

impl<'shape> Unpin for Def<'shape>

§

impl<'shape> UnwindSafe for Def<'shape>

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