Skip to main content

Database

Trait Database 

Source
pub trait Database:
    Send
    + Sync
    + 'static {
    // Required methods
    fn url(&self) -> &str;
    fn system(&self) -> &'static str;

    // Provided method
    fn pool(&self) -> Option<&dyn AnyPool> { ... }
}

Required Methods§

Source

fn url(&self) -> &str

Connection URL — e.g. postgres://user:pass@host:5432/db. Per design Q4, default impls read this from the DATABASE_URL env var the deployment template injects.

Source

fn system(&self) -> &'static str

Span attribute db.system. Implementations return one of "postgres" | "mysql" | "sqlite" | "clickhouse".

Provided Methods§

Source

fn pool(&self) -> Option<&dyn AnyPool>

Optional framework-managed pool. Default None.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§