2024-03-22 05:13:17 -05:00
|
|
|
use {
|
|
|
|
alloc::{string::String, vec::Vec},
|
|
|
|
hashbrown::HashMap,
|
|
|
|
};
|
2024-08-19 13:13:58 -05:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2024-03-22 05:13:17 -05:00
|
|
|
pub struct Type {}
|
2024-08-19 13:13:58 -05:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2024-03-22 05:13:17 -05:00
|
|
|
pub struct Funct {
|
|
|
|
takes: Vec<String>,
|
|
|
|
gives: Vec<String>,
|
|
|
|
}
|
2024-08-19 13:13:58 -05:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2024-09-13 16:41:31 -05:00
|
|
|
pub struct Protocol<'a> {
|
|
|
|
types: HashMap<&'a str, Type>,
|
|
|
|
fns: HashMap<&'a str, Funct>,
|
2024-03-22 05:13:17 -05:00
|
|
|
}
|
2024-09-13 16:41:31 -05:00
|
|
|
impl<'a> Protocol<'a> {
|
2024-03-22 05:13:17 -05:00
|
|
|
pub fn void() -> Self {
|
|
|
|
Self {
|
|
|
|
types: HashMap::new(),
|
|
|
|
fns: HashMap::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Check if a protocol defines all types it needs too
|
|
|
|
fn validate_protocol() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-13 16:41:31 -05:00
|
|
|
impl<'a> From<&'a str> for Protocol<'a> {
|
|
|
|
fn from(value: &'a str) -> Self {
|
2024-08-12 08:15:50 -05:00
|
|
|
let mut hm_t = HashMap::new();
|
|
|
|
hm_t.insert(value, Type {});
|
2024-03-22 05:13:17 -05:00
|
|
|
Self {
|
2024-08-12 08:15:50 -05:00
|
|
|
types: hm_t,
|
2024-03-22 05:13:17 -05:00
|
|
|
fns: HashMap::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|