use std::collections::HashMap;
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq)]
pub enum AttributeValue {
I64(i64),
F64(f64),
String(String),
Bool(bool),
}
#[non_exhaustive]
#[derive(Clone, Debug, Default)]
pub struct Attributes {
attrs: HashMap<String, AttributeValue>,
}
impl Attributes {
pub fn new() -> Self {
Self::default()
}
pub fn set(&mut self, key: impl Into<String>, value: impl Into<AttributeValue>) {
self.attrs.insert(key.into(), value.into());
}
pub fn get(&self, key: impl Into<String>) -> Option<&AttributeValue> {
self.attrs.get(&key.into())
}
pub fn attributes(&self) -> &HashMap<String, AttributeValue> {
&self.attrs
}
pub fn into_attributes(self) -> impl Iterator<Item = (String, AttributeValue)> {
self.attrs.into_iter()
}
}