use serde::{Deserialize, Serialize};
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
Serialize,
Deserialize,
zerompk::ToMessagePack,
zerompk::FromMessagePack,
)]
#[serde(rename_all = "snake_case")]
#[msgpack(c_enum)]
pub enum AttrType {
Int64,
Float64,
String,
Bytes,
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
Serialize,
Deserialize,
zerompk::ToMessagePack,
zerompk::FromMessagePack,
)]
pub struct AttrSpec {
pub name: String,
pub dtype: AttrType,
pub nullable: bool,
}
impl AttrSpec {
pub fn new(name: impl Into<String>, dtype: AttrType, nullable: bool) -> Self {
Self {
name: name.into(),
dtype,
nullable,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn attr_spec_round_trip_eq() {
let a = AttrSpec::new("qual", AttrType::Float64, true);
let b = a.clone();
assert_eq!(a, b);
}
}