rok-tenant 0.3.9

Multi-tenancy support for the rok ecosystem (row-level and schema-level isolation)
Documentation
//! rok-tenant — Multi-tenancy for the rok ecosystem.
//!
//! Provides row-level tenant isolation via task-local tenant ID storage and a
//! Tower middleware that resolves the tenant per request.
//!
//! Two resolution strategies are supported:
//!
//! - **Shared table** — A `tenant_id` column is filtered automatically via a
//!   global scope when `#[model(tenant_scoped)]` is applied.
//! - **Separate schemas** — Use [`TenantSource::Subdomain`] to route each
//!   request to a dedicated PostgreSQL schema (integration with `rok-orm`
//!   schema switching is handled by the ORM layer).
//!
//! # Quick start
//!
//! ```rust,ignore
//! use rok_tenant::{TenantLayer, TenantSource, current_tenant_id};
//!
//! // Extract tenant from X-Tenant-ID header
//! let app = Router::new()
//!     .nest("/", routes())
//!     .layer(TenantLayer::from_header("X-Tenant-ID"));
//!
//! // Or from the subdomain
//! let app = Router::new()
//!     .nest("/", routes())
//!     .layer(TenantLayer::from_subdomain());
//!
//! // Inside a handler or model method:
//! let tenant = current_tenant_id(); // → Option<i64>
//! ```

pub use rok_orm_core::tenant::current_tenant_id;
pub use rok_orm_core::tenant::{TenantLayer, TenantSource};

pub mod error;
pub use error::TenantError;