Struct quire::validate::Enum [−][src]
pub struct Enum<'a> { /* fields omitted */ }
Enum validator
This validates that the value is enum in the rust meaning of enum.
Enumeration can contain:
-
A selection from constants:
enum T {a, b, c}
, if you enableallow_plain()
, this allows to select both as scalar valuea
and as a tag with null value!a
-
A set of different values with their own data:
enum T { a(x), b(y) }
. In this case value must be specified with tag!a "hello"
and may contain different types inside!b ["x", "y"]
or!c {x: y}
. Only one enum field is supported. Structure enumsenum T { a { x: u8 }
are equivalent to an option with that struct as single valuestruct A { x: u8 }; enum T { a(A) }
Methods
impl<'a> Enum<'a>
[src]
impl<'a> Enum<'a>
pub fn new() -> Enum<'a>
[src]
pub fn new() -> Enum<'a>
pub fn optional(self) -> Enum<'a>
[src]
pub fn optional(self) -> Enum<'a>
pub fn allow_plain(self) -> Enum<'a>
[src]
pub fn allow_plain(self) -> Enum<'a>
For variants that have no content (i.e. have validator of Nothing)
pub fn plain_default<S: ToString>(self, value: S) -> Enum<'a>
[src]
pub fn plain_default<S: ToString>(self, value: S) -> Enum<'a>
Set plain default value (i.e. option that have validator of Nothing)
There is no way to set default to something complex at the moment
pub fn option<S: ToString, V: Validator + 'a>(
self,
name: S,
value: V
) -> Enum<'a>
[src]
pub fn option<S: ToString, V: Validator + 'a>(
self,
name: S,
value: V
) -> Enum<'a>
pub fn default_tag<S: ToString>(self, name: S) -> Enum<'a>
[src]
pub fn default_tag<S: ToString>(self, name: S) -> Enum<'a>
Trait Implementations
impl<'a> Debug for Enum<'a>
[src]
impl<'a> Debug for Enum<'a>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'a> Validator for Enum<'a>
[src]
impl<'a> Validator for Enum<'a>