atc_router/
schema.rs

1use crate::ast::Type;
2use std::collections::HashMap;
3
4#[derive(Default)]
5pub struct Schema {
6    fields: HashMap<String, Type>,
7}
8
9impl Schema {
10    pub fn type_of(&self, field: &str) -> Option<&Type> {
11        self.fields.get(field).or_else(|| {
12            self.fields
13                .get(&format!("{}.*", &field[..field.rfind('.')?]))
14        })
15    }
16
17    pub fn add_field(&mut self, field: &str, typ: Type) {
18        self.fields.insert(field.to_string(), typ);
19    }
20}