pub struct TenantScope { /* private fields */ }Expand description
A scoped tenant context that tracks whether it’s been entered.
This provides an alternative to with_tenant for cases where you
need more control over the scope.
§Example
ⓘ
use prax_query::tenant::task_local::TenantScope;
async fn handle_request(tenant_id: &str) {
let scope = TenantScope::new(tenant_id);
scope.run(async {
// tenant context active here
}).await;
}Implementations§
Source§impl TenantScope
impl TenantScope
Sourcepub fn from_context(context: TenantContext) -> Self
pub fn from_context(context: TenantContext) -> Self
Create from a full context.
Sourcepub fn context(&self) -> &TenantContext
pub fn context(&self) -> &TenantContext
Get the full context.
Trait Implementations§
Source§impl Clone for TenantScope
impl Clone for TenantScope
Source§fn clone(&self) -> TenantScope
fn clone(&self) -> TenantScope
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 moreAuto Trait Implementations§
impl Freeze for TenantScope
impl !RefUnwindSafe for TenantScope
impl Send for TenantScope
impl Sync for TenantScope
impl Unpin for TenantScope
impl !UnwindSafe for TenantScope
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