pub trait TenantColumn:
Sized
+ Field
+ IntoExpr<Self>
+ Send
+ Sync
+ 'static {
// Required method
fn from_tenant(id: Uuid) -> Self;
}Expand description
A field type a tenancy names: TenantId, or Option<TenantId> for a
nullable column.
Implement it for an app’s own newtype to name that instead. uuid::Uuid cannot implement it:
neither the trait nor the type belongs to the app, so an unmarked UUID column can never be
named as a tenant column.
ⓘ
#[derive(Debug, Clone, toasty::Model)]
struct Post {
#[key]
#[auto]
id: uuid::Uuid,
#[index]
tenant_id: TenantId,
author_id: uuid::Uuid,
}
// `author_id` is a `Uuid`: the lens names no tenant column.
let _ = Tenancy::column(Post::fields().author_id());Required Methods§
Sourcefn from_tenant(id: Uuid) -> Self
fn from_tenant(id: Uuid) -> Self
The column’s value for the request tenant id.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".