Skip to main content

SchemaInspector

Trait SchemaInspector 

Source
pub trait SchemaInspector: Send + Sync {
    // Required methods
    fn inspect_schema<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tenant: &'life1 TenantContext,
    ) -> Pin<Box<dyn Future<Output = Result<SchemaSnapshot>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn schema_exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tenant: &'life1 TenantContext,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_tenants<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<TenantContext>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Schema inspector trait for read-only schema introspection

This trait abstracts the process of reading schema information from a database. Implementations are database-specific but produce database-agnostic SchemaSnapshot objects.

§Design Rationale

Separating inspection from execution allows:

  • Audit mode to work without write permissions
  • Dry-run mode to calculate diffs without locks
  • Testing with mock inspectors
  • Different inspection strategies (cached, streaming, etc.)

Required Methods§

Source

fn inspect_schema<'life0, 'life1, 'async_trait>( &'life0 self, tenant: &'life1 TenantContext, ) -> Pin<Box<dyn Future<Output = Result<SchemaSnapshot>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Inspect the current schema for a tenant

Returns a normalized snapshot of the schema as it currently exists in the database.

§Arguments
  • tenant - The tenant context to inspect
§Errors

Returns an error if:

  • The tenant schema doesn’t exist
  • Database connection fails
  • Schema introspection fails
Source

fn schema_exists<'life0, 'life1, 'async_trait>( &'life0 self, tenant: &'life1 TenantContext, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a tenant schema exists

Source

fn list_tenants<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<TenantContext>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all tenant schemas in the database

This is useful for batch operations across all tenants.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§