pants_store/
schema.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Serialize, Deserialize)]
6pub struct Schema {
7    data: HashMap<String, String>,
8}
9
10impl Schema {
11    pub fn new(data: HashMap<String, String>) -> Self {
12        Self { data }
13    }
14
15    pub fn get(&self, key: &str) -> Option<&String> {
16        self.data.get(key)
17    }
18
19    pub fn keys(self) -> Vec<String> {
20        self.data.into_keys().collect()
21    }
22
23    pub fn all_info(self) -> Vec<String> {
24        self.data
25            .into_iter()
26            .map(|(key, value)| format!("{}: {}", key, value))
27            .collect()
28    }
29}
30
31impl From<HashMap<String, String>> for Schema {
32    fn from(value: HashMap<String, String>) -> Self {
33        Self { data: value }
34    }
35}