pub struct TenantPolicy {
pub table: String,
pub tenant_column: String,
pub tenant_source: TenantSource,
}Expand description
Multi-tenant RLS configuration.
Fields§
§table: StringTable name.
tenant_column: StringTenant ID column name.
tenant_source: TenantSourceSession variable or function to get current tenant.
Implementations§
Source§impl TenantPolicy
impl TenantPolicy
Sourcepub fn new(
table: impl Into<String>,
tenant_column: impl Into<String>,
source: TenantSource,
) -> Self
pub fn new( table: impl Into<String>, tenant_column: impl Into<String>, source: TenantSource, ) -> Self
Create a new tenant policy.
Sourcepub fn to_postgres_rls(&self) -> RlsPolicy
pub fn to_postgres_rls(&self) -> RlsPolicy
Generate PostgreSQL RLS policy for tenant isolation.
Sourcepub fn set_tenant_sql(&self, tenant_id: &str, db_type: DatabaseType) -> String
pub fn set_tenant_sql(&self, tenant_id: &str, db_type: DatabaseType) -> String
Generate SQL to set the tenant context.
Trait Implementations§
Source§impl Clone for TenantPolicy
impl Clone for TenantPolicy
Source§fn clone(&self) -> TenantPolicy
fn clone(&self) -> TenantPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TenantPolicy
impl Debug for TenantPolicy
Source§impl<'de> Deserialize<'de> for TenantPolicy
impl<'de> Deserialize<'de> for TenantPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for TenantPolicy
impl PartialEq for TenantPolicy
Source§impl Serialize for TenantPolicy
impl Serialize for TenantPolicy
impl Eq for TenantPolicy
impl StructuralPartialEq for TenantPolicy
Auto Trait Implementations§
impl Freeze for TenantPolicy
impl RefUnwindSafe for TenantPolicy
impl Send for TenantPolicy
impl Sync for TenantPolicy
impl Unpin for TenantPolicy
impl UnwindSafe for TenantPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more