pub struct ThreadKey { /* private fields */ }Expand description
Canonical addressing tuple for every tenant-scoped persistence
operation — (tenant_id, thread_id). Encodes Invariant 11
(multi-tenant isolation) at the type level so impls cannot
accidentally drop the tenant scope. The tenant_id carries the
validating TenantId newtype, so a ThreadKey whose serde
payload arrived with an empty tenant is rejected at deserialize
time rather than constructed and then silently mis-routed.
Implementations§
Source§impl ThreadKey
impl ThreadKey
Sourcepub fn new(tenant_id: TenantId, thread_id: impl Into<String>) -> Self
pub fn new(tenant_id: TenantId, thread_id: impl Into<String>) -> Self
Build a key from a TenantId (already validated by its
constructor) and a thread_id literal.
§Panics
Panics when thread_id is empty — empty would silently
produce ambiguous keys ("tenant:") that collide across
logically distinct callers, defeating the Invariant 11
isolation this type exists to enforce. Use Self::from_ctx
in production paths; new is intended for tests and
migration tooling that have already validated the inputs.
Sourcepub fn from_ctx(ctx: &ExecutionContext) -> Result<Self>
pub fn from_ctx(ctx: &ExecutionContext) -> Result<Self>
Derive a key from an ExecutionContext. Returns
Error::Config when the context carries no thread_id or
the thread_id is empty — every persistence call requires
both components be non-empty so two rows under different
intent cannot share a key. The tenant_id is taken from the
context’s TenantId (already validated).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ThreadKey
impl<'de> Deserialize<'de> for ThreadKey
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>,
impl Eq for ThreadKey
impl StructuralPartialEq for ThreadKey
Auto Trait Implementations§
impl Freeze for ThreadKey
impl RefUnwindSafe for ThreadKey
impl Send for ThreadKey
impl Sync for ThreadKey
impl Unpin for ThreadKey
impl UnsafeUnpin for ThreadKey
impl UnwindSafe for ThreadKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.