influxc/
value.rs

1//!
2//! InfluxDB Value Variants
3//!
4use std::fmt;
5
6
7/// Type primitives as supported by InfluxDB and their conversions from/to Rust primitives
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub enum Value
10{
11    /// Self explanatory integer type
12    #[serde(rename="i64")] Integer(i64),
13
14    /// Self explanatory float type
15    #[serde(rename="f64")] Float(f64),
16
17    /// Self explanatory string type
18    #[serde(rename="str")] String(String),
19
20    /// Self explanatory boolean type
21    #[serde(rename="bool")] Boolean(bool),
22
23}
24
25
26impl fmt::Display for Value
27{
28    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
29    {
30        match self
31        {
32            Value::Integer(v) => v.fmt(f),
33            Value::Float(v)   => v.fmt(f),
34            Value::String(v)  => v.fmt(f),
35            Value::Boolean(v) => v.fmt(f),
36        }
37    }
38}
39
40
41impl From<i64>    for Value { fn from(other: i64)    -> Self { Value::Integer(other) }}
42impl From<f64>    for Value { fn from(other: f64)    -> Self { Value::Float(other) }}
43impl From<String> for Value { fn from(other: String) -> Self { Value::String(other) }}
44impl From<bool>   for Value { fn from(other: bool)   -> Self { Value::Boolean(other) }}