pub struct Schema {
pub tables: AHashMap<String, TableId>,
pub table_schemas: Vec<TableSchema>,
}Expand description
Complete database schema
Fields§
§tables: AHashMap<String, TableId>Map from table name to table ID
table_schemas: Vec<TableSchema>Table schemas indexed by TableId
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn from_sql_file(
path: &Path,
dialect: SqlDialect,
progress_fn: Option<Box<dyn Fn(u64)>>,
) -> Result<Schema>
pub fn from_sql_file( path: &Path, dialect: SqlDialect, progress_fn: Option<Box<dyn Fn(u64)>>, ) -> Result<Schema>
Build a Schema by streaming the DDL statements of a SQL file.
Opens path via open_input_opt_progress, so all supported
compression formats (including zip archives) are handled
transparently. When progress_fn is Some, it receives cumulative
raw bytes read from disk.
Source§impl Schema
impl Schema
Sourcepub fn get_table_id(&self, name: &str) -> Option<TableId>
pub fn get_table_id(&self, name: &str) -> Option<TableId>
Get table ID by name (case-insensitive)
Sourcepub fn table(&self, id: TableId) -> Option<&TableSchema>
pub fn table(&self, id: TableId) -> Option<&TableSchema>
Get table schema by ID
Sourcepub fn table_mut(&mut self, id: TableId) -> Option<&mut TableSchema>
pub fn table_mut(&mut self, id: TableId) -> Option<&mut TableSchema>
Get mutable table schema by ID
Sourcepub fn get_table(&self, name: &str) -> Option<&TableSchema>
pub fn get_table(&self, name: &str) -> Option<&TableSchema>
Get table schema by name
Sourcepub fn add_table(&mut self, schema: TableSchema) -> TableId
pub fn add_table(&mut self, schema: TableSchema) -> TableId
Add a new table schema, returning its ID
Sourcepub fn resolve_foreign_keys(&mut self)
pub fn resolve_foreign_keys(&mut self)
Resolve all foreign key references to table IDs
Sourcepub fn iter(&self) -> impl Iterator<Item = &TableSchema>
pub fn iter(&self) -> impl Iterator<Item = &TableSchema>
Iterate over all table schemas
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more