Trait csvenum::RTypeTrait

source ·
pub trait RTypeTrait {
    // Required methods
    fn from_typestr<T: AsRef<str>>(typestr: T) -> Result<Self, TypeError>
       where Self: Sized;
    fn to_typestr(&self) -> String;
    fn to_typestr_no_ref(&self) -> String;
    fn to_typestr_no_life(&self) -> String;
    fn collect_lifetimes(&self, into: &mut Vec<String>);
    fn get_depth(&self, counter: usize) -> usize;
    fn get_breadth(&self, counter: usize) -> usize;
    fn is_const(&self) -> bool;
    fn value_is_valid(&self, valuestr: &str) -> bool;
    fn wrap_valuestr(&self, valuestr: &str) -> String;
    fn can_match_as_key(&self) -> bool;
}
Expand description

Trait to simplify handling types

Required Methods§

source

fn from_typestr<T: AsRef<str>>(typestr: T) -> Result<Self, TypeError>
where Self: Sized,

Construct the RType from a string that contains type information i.e. “ &str “

-> will return RType::String(Reference::Naked, StringType::str)

source

fn to_typestr(&self) -> String

Conversions into type representation

Example input: &'a str

get normal representation &'a str

source

fn to_typestr_no_ref(&self) -> String

get representation without references or lifetimes str

source

fn to_typestr_no_life(&self) -> String

get representation without lifetime &str

source

fn collect_lifetimes(&self, into: &mut Vec<String>)

collect lifetimes

source

fn get_depth(&self, counter: usize) -> usize

Get nesting depth

source

fn get_breadth(&self, counter: usize) -> usize

Get nesting breadth

source

fn is_const(&self) -> bool

  1. get if the type can be declared as const
source

fn value_is_valid(&self, valuestr: &str) -> bool

  1. Value is valid - assume an input of (2,2,[2,3,4]) -> Tuple(NumType,NumType,Array|Vec)

Array|Vec in this case means that [2,3,4] is a valid declaration in text for array and vec tho vec can also have vec! prefixed

source

fn wrap_valuestr(&self, valuestr: &str) -> String

source

fn can_match_as_key(&self) -> bool

Whether the type can be used as the key in a match expression, floats can not.

Implementors§