Skip to main content

SqlBackends

Trait SqlBackends 

Source
pub trait SqlBackends: Send + Sync {
    // Required method
    fn database<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        project: &'life1 str,
        site: &'life2 str,
        name: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SqlBackend>, SqlError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;

    // Provided method
    fn preview_database<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        project: &'life1 str,
        site: &'life2 str,
        name: &'life3 str,
        preview: &'life4 str,
    ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SqlBackend>, SqlError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait { ... }
}
Expand description

Resolves a site’s named SQL databases to SqlBackends — the seam the server’s handler runtime uses to obtain a per-site database on demand (opening/caching it lazily). The concrete mapping (a libsql file per site, or a sqld namespace per site) lives behind this, so the server stays storage-agnostic.

Required Methods§

Source

fn database<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, project: &'life1 str, site: &'life2 str, name: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SqlBackend>, SqlError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Open (or reuse) the database called name for site within tenant project (the empty name is the site’s default database). Per-tenant + per-site isolation is the implementation’s responsibility — a handler can only ever reach its own project’s site’s data.

project and site are separately validated by the implementation and composed internally via ProjectRef::qualified (the reserved default project keeps the byte-identical, pre-project identity for back-compat; any other project prefixes "<project>/"). Passing a single already-composed "<project>/<site>" string as site would be rejected — the two names are kept apart so each is validated on its own.

Provided Methods§

Source

fn preview_database<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, project: &'life1 str, site: &'life2 str, name: &'life3 str, preview: &'life4 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SqlBackend>, SqlError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Open (or reuse) the database for a preview deployment preview of site within tenant project. The implementation applies its configured PreviewSqlMode. The default is PreviewSqlMode::Empty — an isolated database keyed by project+site+preview, so a preview can never touch live state. The default composition qualifies site by project first, then appends the trusted _preview/{preview} suffix (both from validated parts), and delegates to database under the reserved default project so the already-qualified identity is not re-qualified.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§