Enum entity::PrimitiveType[][src]

pub enum PrimitiveType {
    Bool,
    Char,
    Number(NumberType),
    Unit,
}

Represents primitive value types

Variants

Bool
Char
Number(NumberType)
Unit

Implementations

impl PrimitiveType[src]

pub fn is_bool(&self) -> bool[src]

pub fn is_char(&self) -> bool[src]

pub fn is_number(&self) -> bool[src]

pub fn is_unit(&self) -> bool[src]

pub fn to_number_type(&self) -> Option<NumberType>[src]

pub fn from_type_name(tname: &str) -> Result<Self, ParseError>[src]

Constructs a primitive value type from a Rust-based type string similar to what you would find from std::any::type_name

Examples

use entity::{PrimitiveType as PVT, NumberType as NT};

assert_eq!(
    PVT::from_type_name("bool").unwrap(),
    PVT::Bool,
);

assert_eq!(
    PVT::from_type_name("char").unwrap(),
    PVT::Char,
);

assert_eq!(
    PVT::from_type_name("u8").unwrap(),
    PVT::Number(NT::U8),
);

assert_eq!(
    PVT::from_type_name("()").unwrap(),
    PVT::Unit,
);

Trait Implementations

impl Clone for PrimitiveType[src]

impl Copy for PrimitiveType[src]

impl Debug for PrimitiveType[src]

impl Default for PrimitiveType[src]

fn default() -> Self[src]

Returns default primitive value type of unit

impl Display for PrimitiveType[src]

impl Eq for PrimitiveType[src]

impl<'a> From<&'a Primitive> for PrimitiveType[src]

impl From<Primitive> for PrimitiveType[src]

impl From<PrimitiveType> for ValueType[src]

fn from(t: PrimitiveType) -> Self[src]

Converts primitive value type to a value type

impl FromStr for PrimitiveType[src]

type Err = ParseError

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Self, Self::Err>[src]

Parses a primitive value type

Examples

use entity::{PrimitiveType as PVT, NumberType as NT};
use strum::ParseError;
use std::str::FromStr;

assert_eq!(PVT::from_str("bool").unwrap(), PVT::Bool);
assert_eq!(PVT::from_str("char").unwrap(), PVT::Char);
assert_eq!(PVT::from_str("u32").unwrap(), PVT::Number(NT::U32));
assert_eq!(PVT::from_str("number:u32").unwrap(), PVT::Number(NT::U32));
assert_eq!(PVT::from_str("unit").unwrap(), PVT::Unit);
assert_eq!(PVT::from_str("unknown").unwrap_err(), ParseError::VariantNotFound);

impl PartialEq<PrimitiveType> for PrimitiveType[src]

impl StructuralEq for PrimitiveType[src]

impl StructuralPartialEq for PrimitiveType[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.