identity capa

identity-tenant

Multi-tenancy support for Rust applications

Multi-tenancy support for Rust applications

Tieridentity
Roleunclassified (baselined)
Pathcrates/identity/tenant
Edition2021
Targetsidentity_tenant, pg_runtime_contract, pg_tenant_ctx, tenant_ctx
Public items109 across 3 modules
Tests68

What it is for

Multi-tenancy support for Rust applications.

This crate provides library crates for building multi-tenant applications with support for different isolation strategies.

Capabilities

InMemoryTenantResolver

Multi-tenancy support for Rust applications.

Item
pub struct InMemoryTenantResolver
InMemoryTenantResolver :: fn new() -> Self
InMemoryTenantResolver :: fn register(& self, tenant : & Tenant)
InMemoryTenantResolver :: fn resolve_by_domain(& self, domain : & str) -> Option <Uuid>
InMemoryTenantResolver :: fn resolve_by_subdomain(& self, subdomain : & str) -> Option <Uuid>
InMemoryTenantResolver :: fn resolve_by_header(& self, value : & str) -> Option <Uuid>
InMemoryTenantResolver :: fn resolve_by_path(& self, segment : & str) -> Option <Uuid>

IsolationStrategy

Multi-tenancy support for Rust applications.

Item
pub enum IsolationStrategy
IsolationStrategy :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

MemberStatus

Multi-tenancy support for Rust applications.

Item
pub enum MemberStatus
MemberStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
MemberStatus :: fn has_access(& self) -> bool
MemberStatus :: fn is_terminal(& self) -> bool

Result

Multi-tenancy support for Rust applications.

Item
pub type Result<T>: std::result::Result <T, TenantError>
fn validate_slug(slug : & str) -> Result <()>

Tenant:Tenant

Multi-tenancy support for Rust applications.

Item
pub struct Tenant

Tenant:activate

Multi-tenancy support for Rust applications.

Item
Tenant :: fn activate(& mut self) -> Result <()>

Tenant:deactivate

Multi-tenancy support for Rust applications.

Item
Tenant :: fn deactivate(& mut self) -> Result <()>

Tenant:effective

Multi-tenancy support for Rust applications.

Item
Tenant :: fn effective_schema(& self) -> & str

Tenant:get

Multi-tenancy support for Rust applications.

Item
Tenant :: fn get_setting <T : for <'de> Deserialize <'de>>(& self, key : & str) -> Option <T>

Tenant:is

Multi-tenancy support for Rust applications.

Item
Tenant :: fn is_accessible(& self) -> bool

Tenant:new

Multi-tenancy support for Rust applications.

Item
Tenant :: fn new(slug : impl Into <String>, name : impl Into <String>) -> Self

Tenant:suspend

Multi-tenancy support for Rust applications.

Item
Tenant :: fn suspend(& mut self, reason : impl Into <String>) -> Result <()>

Tenant:with

Multi-tenancy support for Rust applications.

Item
Tenant :: fn with_tier(mut self, tier : TenantTier) -> Self
Tenant :: fn with_isolation(mut self, isolation : IsolationStrategy) -> Self
Tenant :: fn with_domain(mut self, domain : impl Into <String>) -> Self
Tenant :: fn with_additional_domain(mut self, domain : impl Into <String>) -> Self
Tenant :: fn with_setting(mut self, key : impl Into <String>, value : impl Serialize) -> Self

TenantContext

Multi-tenancy support for Rust applications.

Item
pub struct TenantContext
TenantContext :: fn from_tenant(tenant : & Tenant) -> Self
TenantContext :: fn with_data(mut self, key : impl Into <String>, value : impl Serialize) -> Self

TenantError

Multi-tenancy support for Rust applications.

Item
pub enum TenantError

TenantFeatures

Multi-tenancy support for Rust applications.

Item
pub struct TenantFeatures
TenantFeatures :: fn is_enabled(& self, feature : & str) -> bool
TenantFeatures :: fn enable(& mut self, feature : impl Into <String>)
TenantFeatures :: fn disable(& mut self, feature : impl Into <String>)
TenantFeatures :: fn get_config <T : for <'de> Deserialize <'de>>(& self, feature : & str) -> Option <T>

TenantMember

Multi-tenancy support for Rust applications.

Item
pub struct TenantMember
TenantMember :: fn new(tenant_id : Uuid, user_id : Uuid, role : TenantRole) -> Self
TenantMember :: fn new_invited(tenant_id : Uuid, user_id : Uuid, role : TenantRole, invited_by : Uuid, invite_token : String, expires_in_days : i64,) -> Self
TenantMember :: fn has_access(& self) -> bool
TenantMember :: fn is_pending(& self) -> bool
TenantMember :: fn is_invite_valid(& self) -> bool
TenantMember :: fn accept(& mut self)
TenantMember :: fn remove(& mut self)
TenantMember :: fn change_role(& mut self, role : TenantRole)
TenantMember :: fn regenerate_invite(& mut self, invite_token : String, expires_in_days : i64)
TenantMember :: fn tenant_id(& self) -> Uuid

TenantQuotas

Multi-tenancy support for Rust applications.

Item
pub struct TenantQuotas
TenantQuotas :: fn default() -> Self
TenantQuotas :: fn unlimited() -> Self
TenantQuotas :: fn is_exceeded(& self, quota : & str, current : u64) -> bool
TenantQuotas :: fn with_custom_quota(mut self, name : impl Into <String>, limit : u64) -> Self

TenantResolver

Multi-tenancy support for Rust applications.

Item
pub trait TenantResolver

TenantRole

Multi-tenancy support for Rust applications.

Item
pub enum TenantRole
TenantRole :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
TenantRole :: fn has_permission(self, target : TenantRole) -> bool

TenantScoped

Multi-tenancy support for Rust applications.

Item
pub trait TenantScoped

TenantStatus

Multi-tenancy support for Rust applications.

Item
pub enum TenantStatus
TenantStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
TenantStatus :: fn is_accessible(& self) -> bool
TenantStatus :: fn is_terminal(& self) -> bool
TenantStatus :: fn can_transition_to(& self, target : TenantStatus) -> bool

TenantTier

Multi-tenancy support for Rust applications.

Item
pub enum TenantTier
TenantTier :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

TenantUsage

Multi-tenancy support for Rust applications.

Item
pub struct TenantUsage
TenantUsage :: fn check_quotas(& self, quotas : & TenantQuotas) -> Vec <String>

verb:accept

Repository functions for tenant models.

Item
async fn accept_invitation(pool : & PgPool, invite_token : & str,) -> Result <Option <TenantMember>, TenantError>

verb:create

Repository functions for tenant models.

Item
async fn create_tenant(pool : & PgPool, name : & str, slug : & str) -> Result <Uuid, TenantError>
async fn create_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid, role : TenantRole,) -> Result <TenantMember, TenantError>
async fn create_invited_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid, role : TenantRole, invited_by : Uuid, expires_in_days : i64,) -> Result <TenantMember, TenantError>

verb:generate

Repository functions for tenant models.

Item
fn generate_invite_token() -> String

verb:get

Repository functions for tenant models.

Item
async fn get_tenant_by_id(pool : & PgPool, tenant_id : Uuid,) -> Result <Option <Tenant>, TenantError>
async fn get_tenant_by_slug(pool : & PgPool, slug : & str) -> Result <Option <Tenant>, TenantError>
async fn get_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid,) -> Result <Option <TenantMember>, TenantError>
async fn get_member_by_token(pool : & PgPool, invite_token : & str,) -> Result <Option <TenantMember>, TenantError>
async fn get_member_role(pool : & PgPool, tenant_id : Uuid, user_id : Uuid,) -> Result <Option <TenantRole>, TenantError>

verb:is

Repository functions for tenant models.

Item
async fn is_active_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid,) -> Result <bool, TenantError>

verb:list

Repository functions for tenant models.

Item
async fn list_members(pool : & PgPool, tenant_id : Uuid,) -> Result <Vec <TenantMember>, TenantError>
async fn list_tenants_for_user(pool : & PgPool, user_id : Uuid,) -> Result <Vec <(Uuid, TenantRole)>, TenantError>

verb:remove

Repository functions for tenant models.

Item
async fn remove_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid,) -> Result <(), TenantError>

verb:update

Repository functions for tenant models.

Item
async fn update_member_role(pool : & PgPool, tenant_id : Uuid, user_id : Uuid, new_role : TenantRole,) -> Result <(), TenantError>

MembershipDetail

Repository functions for tenant models.

Item
pub struct MembershipDetail
async fn list_membership_details(pool : & PgPool, user_id : Uuid,) -> Result <Vec <MembershipDetail>, TenantError>

MemberService

Service layer for tenant operations.

Item
pub struct MemberService<'a>

MemberService<'a>

Service layer for tenant operations.

Item
MemberService<'a> :: fn new(pool : & 'a PgPool) -> Self
MemberService<'a> :: async fn invite(& self, tenant_id : Uuid, user_id : Uuid, role : TenantRole, invited_by : Uuid, expires_in_days : i64,) -> Result <TenantMember, TenantError>
MemberService<'a> :: async fn accept_invitation(& self, invite_token : & str,) -> Result <Option <TenantMember>, TenantError>
MemberService<'a> :: async fn get(& self, tenant_id : Uuid, user_id : Uuid,) -> Result <Option <TenantMember>, TenantError>
MemberService<'a> :: async fn list(& self, tenant_id : Uuid) -> Result <Vec <TenantMember>, TenantError>
MemberService<'a> :: async fn list_tenants_for_user(& self, user_id : Uuid,) -> Result <Vec <(Uuid, TenantRole)>, TenantError>
MemberService<'a> :: async fn update_role(& self, tenant_id : Uuid, user_id : Uuid, new_role : TenantRole, changed_by : Uuid,) -> Result <(), TenantError>
MemberService<'a> :: async fn remove(& self, tenant_id : Uuid, user_id : Uuid, removed_by : Uuid,) -> Result <(), TenantError>
MemberService<'a> :: async fn is_active_member(& self, tenant_id : Uuid, user_id : Uuid,) -> Result <bool, TenantError>
MemberService<'a> :: async fn get_role(& self, tenant_id : Uuid, user_id : Uuid,) -> Result <Option <TenantRole>, TenantError>

TenantService

Service layer for tenant operations.

Item
pub struct TenantService<'a>

TenantService<'a>

Service layer for tenant operations.

Item
TenantService<'a> :: fn new(pool : & 'a PgPool) -> Self
TenantService<'a> :: async fn create_with_owner(& self, name : & str, slug : & str, owner_user_id : Uuid,) -> Result <(Uuid, TenantMember), TenantError>
TenantService<'a> :: async fn get_by_id(& self, tenant_id : Uuid) -> Result <Option <Tenant>, TenantError>
TenantService<'a> :: async fn get_by_slug(& self, slug : & str) -> Result <Option <Tenant>, TenantError>

tenant_ctx (other)

Tenant context for row-level-security policies (Sprint 3.2 D1, B-039).

Item
pub const GUC_NAME: & str
pub const SYSTEM_SCOPE: & str
async fn bind_raw_value <'c, E>(executor : E, value : & str) -> Result <(), sqlx::Error> where E : sqlx::Executor <'c, Database = sqlx::Postgres>,

TenantScope

Tenant context for row-level-security policies (Sprint 3.2 D1, B-039).

Item
pub enum TenantScope
TenantScope :: fn for_row_tenant(tenant : Option <Uuid>) -> Self
TenantScope :: fn see_all_if_global(is_global : bool) -> Self
TenantScope :: fn is_see_all(self) -> bool
TenantScope :: fn guc_value(self) -> String
async fn bind_scope <'c, E>(executor : E, scope : TenantScope) -> Result <(), sqlx::Error> where E : sqlx::Executor <'c, Database = sqlx::Postgres>,

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

identity_tenant

flowchart TD
  n_identity_tenant["identity_tenant"]
  n_identity_tenant --> n_repo["repo"]
  n_identity_tenant --> n_service["service"]
  n_identity_tenant --> n_tenant_ctx["tenant_ctx"]

Public surface

`crate root`

ItemWhat it is
pub enum TenantErrorErrors that can occur with tenant operations.
pub type Result<T>: std::result::Result <T, TenantError>Result type for tenant operations.
fn validate_slug(slug : & str) -> Result <()>Validates a tenant slug
pub enum IsolationStrategyTenant isolation strategy.
IsolationStrategy :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub enum TenantStatusTenant status.
TenantStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
TenantStatus :: fn is_accessible(& self) -> boolReturns true if the tenant can be accessed.
TenantStatus :: fn is_terminal(& self) -> boolReturns true if the tenant is in a terminal state.
TenantStatus :: fn can_transition_to(& self, target : TenantStatus) -> boolReturns true if the tenant can transition to the target status.
pub enum TenantTierTenant tier/plan.
TenantTier :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub enum TenantRoleRole of a member within a tenant.
TenantRole :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub enum MemberStatusStatus of a tenant membership.
MemberStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
MemberStatus :: fn has_access(& self) -> boolReturns true if the member has access to the tenant.
MemberStatus :: fn is_terminal(& self) -> boolReturns true if this is a terminal state.
TenantRole :: fn has_permission(self, target : TenantRole) -> boolReturns true if this role has permission over the target role.
pub struct TenantMemberA member of a tenant.
TenantMember :: fn new(tenant_id : Uuid, user_id : Uuid, role : TenantRole) -> SelfCreates a new active tenant member (direct add, no invite).
TenantMember :: fn new_invited(tenant_id : Uuid, user_id : Uuid, role : TenantRole, invited_by : Uuid, invite_token : String, expires_in_days : i64,) -> SelfCreates a new invited member (pending acceptance).
TenantMember :: fn has_access(& self) -> boolReturns true if the member has access to the tenant.
TenantMember :: fn is_pending(& self) -> boolReturns true if the invite is pending.
TenantMember :: fn is_invite_valid(& self) -> boolReturns true if the invite token is still valid.
TenantMember :: fn accept(& mut self)Accepts the invitation, activating the membership.
TenantMember :: fn remove(& mut self)Removes the member (soft delete).
TenantMember :: fn change_role(& mut self, role : TenantRole)Changes the member's role.
TenantMember :: fn regenerate_invite(& mut self, invite_token : String, expires_in_days : i64)Regenerates the invite token with a new expiry.
pub struct TenantA tenant in the system.
Tenant :: fn new(slug : impl Into <String>, name : impl Into <String>) -> SelfCreates a new tenant.
Tenant :: fn with_tier(mut self, tier : TenantTier) -> SelfSets the tenant tier.
Tenant :: fn with_isolation(mut self, isolation : IsolationStrategy) -> SelfSets the isolation strategy.
Tenant :: fn with_domain(mut self, domain : impl Into <String>) -> SelfSets the primary domain.
Tenant :: fn with_additional_domain(mut self, domain : impl Into <String>) -> SelfAdds an additional domain.
Tenant :: fn with_setting(mut self, key : impl Into <String>, value : impl Serialize) -> SelfSets a setting value.
Tenant :: fn activate(& mut self) -> Result <()>Activates the tenant
Tenant :: fn suspend(& mut self, reason : impl Into <String>) -> Result <()>Suspends the tenant
Tenant :: fn deactivate(& mut self) -> Result <()>Deactivates the tenant
Tenant :: fn is_accessible(& self) -> boolReturns true if the tenant is accessible.
Tenant :: fn get_setting <T : for <'de> Deserialize <'de>>(& self, key : & str) -> Option <T>Gets a setting value.
Tenant :: fn effective_schema(& self) -> & strGets the effective schema name.
pub struct TenantQuotasTenant quota limits.
TenantQuotas :: fn default() -> Self
TenantQuotas :: fn unlimited() -> SelfCreates unlimited quotas.
TenantQuotas :: fn is_exceeded(& self, quota : & str, current : u64) -> boolChecks if a quota limit is exceeded.
TenantQuotas :: fn with_custom_quota(mut self, name : impl Into <String>, limit : u64) -> SelfSets a custom quota.
pub struct TenantContextTenant context for request processing.
TenantContext :: fn from_tenant(tenant : & Tenant) -> SelfCreates a new tenant context from a tenant.
TenantContext :: fn with_data(mut self, key : impl Into <String>, value : impl Serialize) -> SelfSets context data.
pub trait TenantResolverTenant resolver trait for identifying tenants from requests.
pub struct InMemoryTenantResolverIn-memory tenant resolver for testing
InMemoryTenantResolver :: fn new() -> SelfCreates a new resolver.
InMemoryTenantResolver :: fn register(& self, tenant : & Tenant)Registers a tenant
InMemoryTenantResolver :: fn resolve_by_domain(& self, domain : & str) -> Option <Uuid>
InMemoryTenantResolver :: fn resolve_by_subdomain(& self, subdomain : & str) -> Option <Uuid>
InMemoryTenantResolver :: fn resolve_by_header(& self, value : & str) -> Option <Uuid>
InMemoryTenantResolver :: fn resolve_by_path(& self, segment : & str) -> Option <Uuid>
pub struct TenantUsageTenant usage statistics.
TenantUsage :: fn check_quotas(& self, quotas : & TenantQuotas) -> Vec <String>Checks if any quota is exceeded.
pub struct TenantFeaturesTenant feature flags.
TenantFeatures :: fn is_enabled(& self, feature : & str) -> boolChecks if a feature is enabled.
TenantFeatures :: fn enable(& mut self, feature : impl Into <String>)Enables a feature.
TenantFeatures :: fn disable(& mut self, feature : impl Into <String>)Disables a feature.
TenantFeatures :: fn get_config <T : for <'de> Deserialize <'de>>(& self, feature : & str) -> Option <T>Gets feature configuration.
pub trait TenantScopedTrait for entities that belong to a tenant
TenantMember :: fn tenant_id(& self) -> Uuid

`repo`

ItemWhat it is
async fn create_tenant(pool : & PgPool, name : & str, slug : & str) -> Result <Uuid, TenantError>Create a new tenant in the database.
async fn get_tenant_by_id(pool : & PgPool, tenant_id : Uuid,) -> Result <Option <Tenant>, TenantError>Get a tenant by ID.
async fn get_tenant_by_slug(pool : & PgPool, slug : & str) -> Result <Option <Tenant>, TenantError>Get a tenant by slug.
async fn create_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid, role : TenantRole,) -> Result <TenantMember, TenantError>Create a new tenant member (direct add, immediately active).
async fn create_invited_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid, role : TenantRole, invited_by : Uuid, expires_in_days : i64,) -> Result <TenantMember, TenantError>Create an invited tenant member (pending acceptance).
async fn get_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid,) -> Result <Option <TenantMember>, TenantError>Get a member by tenant and user.
async fn get_member_by_token(pool : & PgPool, invite_token : & str,) -> Result <Option <TenantMember>, TenantError>Get a member by invite token.
async fn list_members(pool : & PgPool, tenant_id : Uuid,) -> Result <Vec <TenantMember>, TenantError>List all active members for a tenant.
async fn list_tenants_for_user(pool : & PgPool, user_id : Uuid,) -> Result <Vec <(Uuid, TenantRole)>, TenantError>List tenants for a user (where user is an active member).
pub struct MembershipDetailOne active membership with the tenant's display fields — for a tenant switcher / login response (Sprint 0.55 US-0.55.8b)
async fn list_membership_details(pool : & PgPool, user_id : Uuid,) -> Result <Vec <MembershipDetail>, TenantError>List the user's active memberships with tenant display fields, ordered by tenant name
async fn accept_invitation(pool : & PgPool, invite_token : & str,) -> Result <Option <TenantMember>, TenantError>Accept an invitation (set status to active).
async fn update_member_role(pool : & PgPool, tenant_id : Uuid, user_id : Uuid, new_role : TenantRole,) -> Result <(), TenantError>Update member role.
async fn remove_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid,) -> Result <(), TenantError>Remove a member (set status to removed).
async fn is_active_member(pool : & PgPool, tenant_id : Uuid, user_id : Uuid,) -> Result <bool, TenantError>Check if user is an active member of tenant.
async fn get_member_role(pool : & PgPool, tenant_id : Uuid, user_id : Uuid,) -> Result <Option <TenantRole>, TenantError>Get the role of a user in a tenant.
fn generate_invite_token() -> StringGenerate a secure random invite token.

`service`

ItemWhat it is
pub struct TenantService<'a>Service for managing tenants (households).
TenantService<'a> :: fn new(pool : & 'a PgPool) -> SelfCreate a new tenant service.
TenantService<'a> :: async fn create_with_owner(& self, name : & str, slug : & str, owner_user_id : Uuid,) -> Result <(Uuid, TenantMember), TenantError>Create a new tenant with the creator as owner
TenantService<'a> :: async fn get_by_id(& self, tenant_id : Uuid) -> Result <Option <Tenant>, TenantError>Get a tenant by ID.
TenantService<'a> :: async fn get_by_slug(& self, slug : & str) -> Result <Option <Tenant>, TenantError>Get a tenant by slug.
pub struct MemberService<'a>Service for managing tenant members.
MemberService<'a> :: fn new(pool : & 'a PgPool) -> SelfCreate a new member service.
MemberService<'a> :: async fn invite(& self, tenant_id : Uuid, user_id : Uuid, role : TenantRole, invited_by : Uuid, expires_in_days : i64,) -> Result <TenantMember, TenantError>Invite a user to a tenant
MemberService<'a> :: async fn accept_invitation(& self, invite_token : & str,) -> Result <Option <TenantMember>, TenantError>Accept an invitation by token.
MemberService<'a> :: async fn get(& self, tenant_id : Uuid, user_id : Uuid,) -> Result <Option <TenantMember>, TenantError>Get a member by tenant and user.
MemberService<'a> :: async fn list(& self, tenant_id : Uuid) -> Result <Vec <TenantMember>, TenantError>List all members of a tenant.
MemberService<'a> :: async fn list_tenants_for_user(& self, user_id : Uuid,) -> Result <Vec <(Uuid, TenantRole)>, TenantError>List all tenants a user is an active member of.
MemberService<'a> :: async fn update_role(& self, tenant_id : Uuid, user_id : Uuid, new_role : TenantRole, changed_by : Uuid,) -> Result <(), TenantError>Update a member's role
MemberService<'a> :: async fn remove(& self, tenant_id : Uuid, user_id : Uuid, removed_by : Uuid,) -> Result <(), TenantError>Remove a member from a tenant
MemberService<'a> :: async fn is_active_member(& self, tenant_id : Uuid, user_id : Uuid,) -> Result <bool, TenantError>Check if user is an active member of tenant.
MemberService<'a> :: async fn get_role(& self, tenant_id : Uuid, user_id : Uuid,) -> Result <Option <TenantRole>, TenantError>Get the role of a user in a tenant.

`tenant_ctx`

ItemWhat it is
pub const GUC_NAME: & strThe Postgres GUC the RLS policies in 002_audit_hardening.sql read
pub const SYSTEM_SCOPE: & strThe scope bound for a tenant_id IS NULL write (migration 006)
pub enum TenantScopeThe tenant scope a transaction runs under
TenantScope :: fn for_row_tenant(tenant : Option <Uuid>) -> SelfThe scope for writing a row whose tenant_id is tenant
TenantScope :: fn see_all_if_global(is_global : bool) -> SelfThe only path to cross-tenant breadth
TenantScope :: fn is_see_all(self) -> boolWhether this scope grants cross-tenant read breadth
TenantScope :: fn guc_value(self) -> StringThe string bound to GUC_NAME
async fn bind_scope <'c, E>(executor : E, scope : TenantScope) -> Result <(), sqlx::Error> where E : sqlx::Executor <'c, Database = sqlx::Postgres>,Bind scope for the remainder of the current transaction
async fn bind_raw_value <'c, E>(executor : E, value : & str) -> Result <(), sqlx::Error> where E : sqlx::Executor <'c, Database = sqlx::Postgres>,Bind an already-resolved GUC value for the current transaction

Re-exports. Exported here, defined elsewhere.

ExportDefined in
TenantIdtenant_id::TenantId

Boundary

Reaches into foundation.

Shares tier identity with 7 other crates: identity-auth, identity-identifiers, identity-impersonation, identity-parties, identity-party-places, identity-rbac, identity-user-prefs.

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)identity
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/identity/tenant
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_identity["identity"] --> n_foundation["foundation"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-basemodels`foundationnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
chrono^0.4serdenoalways
hex^0.4noalways
rand^0.8noalways
regex^1noalways
serde^1derivenoalways
serde_json^1noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
thiserror^2noalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio^1fullnoalways

Build. None.

Depended on by. 10 workspace crates.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_audit_log["application-audit-log"] -->|uses| SELF
  n_application_auth["application-auth"] -->|uses| SELF
  n_application_dlp["application-dlp"] -->|uses| SELF
  n_application_rbac["application-rbac"] -->|uses| SELF
  n_application_tenant["application-tenant"] -->|uses| SELF
  n_domain_legal_matter["domain-legal-matter"] -->|uses| SELF
  n_infrastructure_tenant_pool["infrastructure-tenant-pool"] -->|uses| SELF
  n_operations_control_plane["operations-control-plane"] -->|uses| SELF
  n_platform_privacy_scan_api["platform-privacy-scan-api"] -->|uses| SELF
  n_tools_sighting_measure["tools-sighting-measure"] -->|uses| SELF
  SELF["identity-tenant"]
  SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libidentity_tenant`src/lib.rs`
testpg_runtime_contract`tests/pg_runtime_contract.rs`
testpg_tenant_ctx`tests/pg_tenant_ctx.rs`
testtenant_ctx`tests/tenant_ctx.rs`

Error model

Error typeNamed by
TenantErrorResult, accept_invitation, create_invited_member, create_member, create_tenant, get_member, … (16 total)

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimenone detected
database accessyes
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

10 workspace crates depend on this one: application-audit-log, application-auth, application-dlp, application-rbac, application-tenant, domain-legal-matter, infrastructure-tenant-pool, operations-control-plane, platform-privacy-scan-api, tools-sighting-measure.

Verification

KindCount
Unit tests50
Integration tests18
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root17026
repo1703
service201
tenant_ctx5013

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc98109
Public modules with a //! block33
pie showData
    title Public items with rustdoc
    "Documented" : 98
    "No rustdoc detected" : 11

Metrics

MetricValue
Rust source files5
Source lines2406
Code lines1690
Public API items109
Public modules3
Tests68
Examples0
Cargo features0
Direct runtime dependencies10
Workspace reverse dependencies10
pie showData
    title Public API by kind
    "constant" : 2
    "enum" : 7
    "function" : 19
    "method" : 68
    "struct" : 10
    "trait" : 2
    "type alias" : 1
pie showData
    title Rust source composition
    "Code" : 1690
    "Blank or comment" : 716

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las identity · Manual