[][src]Enum entity::PrimitiveValueType

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

Represents primitive value types

Variants

Bool
Char
Number(NumberType)
Unit

Implementations

impl PrimitiveValueType[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::{PrimitiveValueType 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 PrimitiveValueType[src]

impl Copy for PrimitiveValueType[src]

impl Debug for PrimitiveValueType[src]

impl Default for PrimitiveValueType[src]

pub fn default() -> Self[src]

Returns default primitive value type of unit

impl Display for PrimitiveValueType[src]

impl Eq for PrimitiveValueType[src]

impl<'a> From<&'a PrimitiveValue> for PrimitiveValueType[src]

impl From<PrimitiveValue> for PrimitiveValueType[src]

impl From<PrimitiveValueType> for ValueType[src]

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

Converts primitive value type to a value type

impl FromStr for PrimitiveValueType[src]

type Err = ParseError

The associated error which can be returned from parsing.

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

Parses a primitive value type

Examples

use entity::{PrimitiveValueType 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<PrimitiveValueType> for PrimitiveValueType[src]

impl StructuralEq for PrimitiveValueType[src]

impl StructuralPartialEq for PrimitiveValueType[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.