Skip to main content

toolu_orm_core/
schema.rs

1use crate::table::TableDef;
2
3#[derive(Debug, Clone)]
4pub struct SchemaRegistry {
5  tables: Vec<TableDef>,
6}
7
8impl SchemaRegistry {
9  pub fn from_tables(mut tables: Vec<TableDef>) -> Self {
10    tables.sort_by(|a, b| a.name.cmp(&b.name));
11    Self { tables }
12  }
13
14  pub fn tables(&self) -> &[TableDef] {
15    &self.tables
16  }
17
18  pub fn find_table(&self, name: &str) -> Option<&TableDef> {
19    self.tables.iter().find(|t| t.name == name)
20  }
21}