Browse Source

in measure, allow `Option<d128>` fields with "D" prefix

example:

```
let a: Option<d128> = Some(d128::from_str("123.456").unwrap());
let b: Option<d128> = None;
measure!(influx, meas, D(a), D(b));
```

in the `None` case, no field is added at all.
master
Jonathan Strong 4 years ago
parent
commit
5830d1d13c
2 changed files with 8 additions and 1 deletions
  1. +1
    -1
      Cargo.toml
  2. +7
    -0
      src/lib.rs

+ 1
- 1
Cargo.toml View File

@@ -1,6 +1,6 @@
[package] [package]
name = "influx-writer" name = "influx-writer"
version = "0.10.0"
version = "0.10.1"
authors = ["Jonathan Strong <jonathan.strong@gmail.com>"] authors = ["Jonathan Strong <jonathan.strong@gmail.com>"]
edition = "2018" edition = "2018"




+ 7
- 0
src/lib.rs View File

@@ -140,6 +140,13 @@ macro_rules! measure {
(@ea u, $meas:ident, $k:expr, $v:expr) => { $meas = $meas.add_field($k, $crate::OwnedValue::Uuid($v)) }; (@ea u, $meas:ident, $k:expr, $v:expr) => { $meas = $meas.add_field($k, $crate::OwnedValue::Uuid($v)) };
(@ea b, $meas:ident, $k:expr, $v:expr) => { $meas = $meas.add_field($k, $crate::OwnedValue::Boolean(bool::from($v))) }; (@ea b, $meas:ident, $k:expr, $v:expr) => { $meas = $meas.add_field($k, $crate::OwnedValue::Boolean(bool::from($v))) };


(@ea D, $meas:ident, $k:expr, $v:expr) => {
match $v {
Some(v) => { $meas = $meas.add_field($k, $crate::OwnedValue::D128(v)) }
None => {}
}
};

(@as_expr $e:expr) => {$e}; (@as_expr $e:expr) => {$e};


(@count_tags) => {0usize}; (@count_tags) => {0usize};


Loading…
Cancel
Save