Def

Enum Def 

Source
#[repr(C)]
pub enum Def { Undefined, Scalar, Map(MapDef), Set(SetDef), List(ListDef), Array(ArrayDef), Slice(SliceDef), Option(OptionDef), Pointer(PointerDef), }
Expand description

The semantic definition of a shape: is it more like a scalar, a map, a list?

Variants§

§

Undefined

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

§

Scalar

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)

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 heterogenous values, variable size

e.g. Vec<T>

§

Array(ArrayDef)

Fixed-size array of heterogeneous values, fixed size

e.g. [T; 3]

§

Slice(SliceDef)

Slice - a reference to a contiguous sequence of elements

e.g. [T]

§

Option(OptionDef)

Option

e.g. Option<T>

§

Pointer(PointerDef)

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

Implementations§

Source§

impl Def

Source

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

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

Source

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

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

Source

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

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

Source

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

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

Source

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

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

Source

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

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

Source

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

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

Source

pub fn into_pointer(self) -> Result<PointerDef, Self>

Returns the PointerDef wrapped in an Ok if this is a Def::Pointer.

Trait Implementations§

Source§

impl Clone for Def

Source§

fn clone(&self) -> Def

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 Def

Source§

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

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

impl Copy for Def

Auto Trait Implementations§

§

impl Freeze for Def

§

impl RefUnwindSafe for Def

§

impl Send for Def

§

impl Sync for Def

§

impl Unpin for Def

§

impl UnwindSafe for Def

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.