Browse Source

upgrade decimal crate to v2.4, add more robust handling for int conversion errors in AsI64 impls

master
Jonathan Strong 4 years ago
parent
commit
3c9988dd42
2 changed files with 16 additions and 13 deletions
  1. +1
    -1
      Cargo.toml
  2. +15
    -12
      src/lib.rs

+ 1
- 1
Cargo.toml View File

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




+ 15
- 12
src/lib.rs View File

@@ -10,10 +10,11 @@ extern crate slog;


use std::io::Read; use std::io::Read;
use std::sync::Arc; use std::sync::Arc;
use crossbeam_channel::{Sender, Receiver, bounded, SendError};
use std::{thread, mem}; use std::{thread, mem};
use std::time::*; use std::time::*;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::convert::TryInto;
use crossbeam_channel::{Sender, Receiver, bounded, SendError};
use hyper::status::StatusCode; use hyper::status::StatusCode;
use hyper::client::response::Response; use hyper::client::response::Response;
use hyper::Url; use hyper::Url;
@@ -42,17 +43,19 @@ pub trait AsI64 {
fn as_i64(x: Self) -> i64; fn as_i64(x: Self) -> i64;
} }


impl AsI64 for i64 { fn as_i64(x: Self) -> i64 { x } }
impl AsI64 for i32 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for u32 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for u64 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for usize { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for f64 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for f32 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for u16 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for i16 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for u8 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for i8 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for i64 { fn as_i64(x: Self) -> i64 { x } }
impl AsI64 for i32 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for u32 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for u64 { fn as_i64(x: Self) -> i64 { x.try_into().unwrap_or(-999) } }
impl AsI64 for usize { fn as_i64(x: Self) -> i64 { x.try_into().unwrap_or(-999) } }
impl AsI64 for i128 { fn as_i64(x: Self) -> i64 { x.try_into().unwrap_or(-999) } }
impl AsI64 for u128 { fn as_i64(x: Self) -> i64 { x.try_into().unwrap_or(-999) } }
impl AsI64 for f64 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for f32 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for u16 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for i16 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for u8 { fn as_i64(x: Self) -> i64 { x as i64 } }
impl AsI64 for i8 { fn as_i64(x: Self) -> i64 { x as i64 } }


/// Created this so I know what types can be passed through the /// Created this so I know what types can be passed through the
/// `measure!` macro, which used to convert with `as i64` and /// `measure!` macro, which used to convert with `as i64` and


Loading…
Cancel
Save