rustango 0.61.13

Batteries-included web framework for Rust: ORM + migrations + auto-admin + multi-tenancy + audit log + auth (sessions, JWT, OAuth2/OIDC, HMAC) + APIs (ViewSet, OpenAPI auto-derive, JSON:API) + jobs (in-mem + Postgres) + email + media (S3 / R2 / B2 / MinIO + presigned uploads + collections + tags) + production middleware (CSRF, CSP, rate-limiting, compression, idempotency, etc.).
Documentation
//! What the unresolved-tenant router gets in place of a tenant.

use crate::sql::{ExecError, ExistsPool as _, Pool};

use super::org::Org;

/// The registry, handed to the router set by
/// [`crate::server::Builder::unresolved_tenant`] as an `Extension`.
///
/// It holds no tenant: that router runs only when none resolved.
#[derive(Clone)]
#[non_exhaustive]
pub struct TenantRegistry {
    pool: Pool,
}

impl TenantRegistry {
    pub(crate) fn new(pool: Pool) -> Self {
        Self { pool }
    }

    /// The registry pool (orgs, operators), never a tenant's.
    #[must_use]
    pub fn pool(&self) -> &Pool {
        &self.pool
    }

    /// Whether the registry holds any tenant, inactive ones included,
    /// so a suspended tenant does not reopen a first-run wizard.
    ///
    /// # Errors
    /// The registry query failing.
    pub async fn has_tenants(&self) -> Result<bool, ExecError> {
        Org::objects().exists(&self.pool).await
    }
}