1use super::db::DataType;
2use std::fmt;
3use std::option::Option;
4
5#[derive(Debug)]
6pub struct Tag {
7 pub device: String,
8 pub value: Option<String>,
9 pub data_type: DataType,
10}
11
12#[derive(Debug)]
13pub struct QueryTag {
14 pub device: String,
15 pub data_type: DataType,
16}
17
18impl Tag {
19 pub fn new(device: String, value: Option<String>, data_type: DataType) -> Self {
20 Self {
21 device,
22 value,
23 data_type,
24 }
25 }
26
27 pub fn is_success(&self) -> bool {
28 self.value.is_some()
29 }
30}
31
32impl fmt::Display for Tag {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 write!(f, "{}, {:?}, {:?}", self.device, self.value, self.data_type)
35 }
36}