Enum foxbox_taxonomy::values::Range
[−]
[src]
pub enum Range { Leq(Value), Geq(Value), BetweenEq { min: Value, max: Value, }, OutOfStrict { min: Value, max: Value, }, Eq(Value), }
Variants
Leq | Leq(x) accepts any value v such that v <= x. JSONextern crate foxbox_taxonomy; extern crate serde_json; use foxbox_taxonomy::values::*; use foxbox_taxonomy::parse::*; use foxbox_taxonomy::serialize::*; let source = "{ \"Leq\": { \"OnOff\": \"On\" } }"; let parsed = Range::from_str(source).unwrap(); if let Range::Leq(ref leq) = parsed { assert_eq!(*leq, Value::OnOff(OnOff::On)); } else { panic!(); } let as_json = parsed.to_json(&mut MultiPart::new()); let as_string = serde_json::to_string(&as_json).unwrap(); assert_eq!(as_string, "{\"Leq\":{\"OnOff\":\"On\"}}"); | |||||
Geq | Geq(x) accepts any value v such that v >= x. | |||||
BetweenEq | BetweenEq {min, max} accepts any value v such that Fields
| |||||
OutOfStrict | OutOfStrict {min, max} accepts any value v such that Fields
| |||||
Eq | Eq(x) accespts any value v such that v == x |
Methods
impl Range
fn contains(&self, value: &Value) -> bool
Determine if a value is accepted by this range.
fn get_type(&self) -> Result<Type, TypeError>
Get the type associated to this range.
If this range has a min
and a max
with conflicting types,
produce an error.