feat: support converting from BlockType

pull/24376/head
Edd Robinson 2020-06-18 19:49:31 +01:00
parent 3c24b6e10e
commit 9006af8961
2 changed files with 16 additions and 1 deletions

View File

@ -8,3 +8,4 @@ edition = "2018"
[dependencies]
log = "0.4.8"
delorean_tsm = { path = "../delorean_tsm" }

View File

@ -30,9 +30,11 @@
//! assert_eq!(cols[3], ColumnDefinition::new("field2", 3, DataType::Boolean));
//! assert_eq!(cols[4], ColumnDefinition::new("timestamp", 4, DataType::Timestamp));
//! ```
use std::collections::BTreeMap;
use delorean_tsm::BlockType;
use log::warn;
use std::collections::BTreeMap;
use std::convert::From;
/// Represents a specific Line Protocol Tag name
#[derive(Debug, PartialEq)]
@ -68,6 +70,18 @@ pub enum DataType {
Timestamp,
}
impl From<&BlockType> for DataType {
fn from(value: &BlockType) -> Self {
match value {
BlockType::Float => Self::Float,
BlockType::Integer => Self::Integer,
BlockType::Bool => Self::Boolean,
BlockType::Str => Self::String,
BlockType::Unsigned => Self::Integer,
}
}
}
/// Represents a specific Line Protocol Field name
#[derive(Debug, PartialEq)]
pub struct Field {