pub struct SchemaCache {
pub tables: Arc<TablesMap>,
pub relationships: Arc<RelationshipsMap>,
pub routines: Arc<RoutinesMap>,
pub timezones: Arc<HashSet<String>>,
pub representations: Arc<RepresentationsMap>,
pub media_handlers: Arc<MediaHandlerMap>,
}Expand description
Immutable schema cache
This structure holds all introspected database metadata. It is designed to be
immutable and wrapped in ArcSwap for lock-free reads.
Fields§
§tables: Arc<TablesMap>All tables and views by qualified name
relationships: Arc<RelationshipsMap>Relationships indexed by source table
routines: Arc<RoutinesMap>Functions/procedures indexed by qualified name
timezones: Arc<HashSet<String>>Available PostgreSQL timezones
representations: Arc<RepresentationsMap>Data representation mappings
media_handlers: Arc<MediaHandlerMap>Media handler mappings
Implementations§
Source§impl SchemaCache
impl SchemaCache
Sourcepub async fn load<I: DbIntrospector + ?Sized>(
introspector: &I,
config: &AppConfig,
) -> Result<Self, Error>
pub async fn load<I: DbIntrospector + ?Sized>( introspector: &I, config: &AppConfig, ) -> Result<Self, Error>
Load schema cache from database using the provided introspector
Sourcepub fn get_table(&self, qi: &QualifiedIdentifier) -> Option<&Table>
pub fn get_table(&self, qi: &QualifiedIdentifier) -> Option<&Table>
Get a table by qualified identifier
Sourcepub fn get_table_by_name(&self, schema: &str, name: &str) -> Option<&Table>
pub fn get_table_by_name(&self, schema: &str, name: &str) -> Option<&Table>
Get a table by schema and name
Sourcepub fn find_relationships(
&self,
source: &QualifiedIdentifier,
) -> &[AnyRelationship]
pub fn find_relationships( &self, source: &QualifiedIdentifier, ) -> &[AnyRelationship]
Find relationships from a source table
Sourcepub fn find_relationships_to(
&self,
source: &QualifiedIdentifier,
target_name: &str,
) -> Vec<&AnyRelationship>
pub fn find_relationships_to( &self, source: &QualifiedIdentifier, target_name: &str, ) -> Vec<&AnyRelationship>
Find relationships from source to a specific target
Sourcepub fn get_routines(&self, qi: &QualifiedIdentifier) -> Option<&[Routine]>
pub fn get_routines(&self, qi: &QualifiedIdentifier) -> Option<&[Routine]>
Get a routine by qualified identifier
Sourcepub fn get_routines_by_name(
&self,
schema: &str,
name: &str,
) -> Option<&[Routine]>
pub fn get_routines_by_name( &self, schema: &str, name: &str, ) -> Option<&[Routine]>
Get a routine by schema and name
Sourcepub fn is_valid_timezone(&self, tz: &str) -> bool
pub fn is_valid_timezone(&self, tz: &str) -> bool
Check if a timezone is valid
Sourcepub fn table_count(&self) -> usize
pub fn table_count(&self) -> usize
Get the number of tables
Sourcepub fn relationship_count(&self) -> usize
pub fn relationship_count(&self) -> usize
Get the number of relationships
Sourcepub fn routine_count(&self) -> usize
pub fn routine_count(&self) -> usize
Get the number of routines
Sourcepub fn tables_iter(
&self,
) -> impl Iterator<Item = (&QualifiedIdentifier, &Table)>
pub fn tables_iter( &self, ) -> impl Iterator<Item = (&QualifiedIdentifier, &Table)>
Iterate over all tables
Sourcepub fn tables_in_schema(&self, schema: &str) -> impl Iterator<Item = &Table>
pub fn tables_in_schema(&self, schema: &str) -> impl Iterator<Item = &Table>
Iterate over all tables in a specific schema
Trait Implementations§
Source§impl Clone for SchemaCache
impl Clone for SchemaCache
Source§fn clone(&self) -> SchemaCache
fn clone(&self) -> SchemaCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more