pub struct TenantId(/* private fields */);Expand description
Tenant identifier. Opaque string from the auth token, used to scope all
queries. Newtype distinguishes it from UserId at compile time so call
sites cannot accidentally swap tenant and user arguments.
#[serde(transparent)] keeps the on-the-wire and DB JSON representation
as a plain string, so this is a pure compile-time refinement.
Implementations§
Source§impl TenantId
impl TenantId
Sourcepub fn new(s: impl Into<String>) -> Self
pub fn new(s: impl Into<String>) -> Self
Constructs a TenantId, rejecting empty strings.
§Panics
Panics if s is empty. An empty tenant id would silently scope queries
to no rows (or all rows, depending on the ORM) and so represents a
latent authorization bug; it must never reach the data layer.
pub fn as_str(&self) -> &str
pub fn into_inner(self) -> String
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TenantId
impl<'de> Deserialize<'de> for TenantId
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
impl Eq for TenantId
impl StructuralPartialEq for TenantId
Auto Trait Implementations§
impl Freeze for TenantId
impl RefUnwindSafe for TenantId
impl Send for TenantId
impl Sync for TenantId
impl Unpin for TenantId
impl UnsafeUnpin for TenantId
impl UnwindSafe for TenantId
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