pub struct StaticContextProvider {
pub tenant_id: TenantId,
pub subject_id: SubjectId,
pub roles: BTreeSet<String>,
pub entitlements: BTreeSet<String>,
pub locale: String,
}Expand description
Resolves every transport request and scheduled job to one tenant/subject.
x-locale metadata overrides the default locale; everything else is ignored.
Fields§
§tenant_id: TenantIdTenant that owns this record.
subject_id: SubjectIdSubject (user or service principal) acting on or owning this record.
roles: BTreeSet<String>Roles granted to the subject.
entitlements: BTreeSet<String>Product entitlements granted to the subject.
locale: StringBCP 47 locale for user-facing text.
Implementations§
Source§impl StaticContextProvider
impl StaticContextProvider
Sourcepub fn new(tenant_id: &str, subject_id: &str) -> Self
pub fn new(tenant_id: &str, subject_id: &str) -> Self
A provider that answers every request as tenant_id / subject_id
with no roles or entitlements.
§Panics
When either identifier is blank; a test double with an invalid identity is a test bug, not a runtime condition.
Sourcepub fn with_roles(
self,
roles: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_roles( self, roles: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Grant these roles to every resolved context.
Sourcepub fn with_entitlements(
self,
entitlements: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_entitlements( self, entitlements: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Grant these entitlements to every resolved context.
Trait Implementations§
Source§impl Clone for StaticContextProvider
impl Clone for StaticContextProvider
Source§fn clone(&self) -> StaticContextProvider
fn clone(&self) -> StaticContextProvider
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 StaticContextProvider
impl Debug for StaticContextProvider
Source§impl PlatformContextProvider for StaticContextProvider
impl PlatformContextProvider for StaticContextProvider
Source§fn resolve<'life0, 'life1, 'async_trait>(
&'life0 self,
metadata: &'life1 RequestMetadata,
) -> Pin<Box<dyn Future<Output = Result<RequestContext, ContextError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn resolve<'life0, 'life1, 'async_trait>(
&'life0 self,
metadata: &'life1 RequestMetadata,
) -> Pin<Box<dyn Future<Output = Result<RequestContext, ContextError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Resolve one request. Fail closed: an unknown or revoked principal is an error, not an anonymous context.
Source§impl ScheduledContextProvider for StaticContextProvider
impl ScheduledContextProvider for StaticContextProvider
Source§fn resolve_scheduled<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tenant_id: &'life1 TenantId,
subject_id: &'life2 SubjectId,
request_id: &'life3 RequestId,
locale: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<RequestContext, ContextError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn resolve_scheduled<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tenant_id: &'life1 TenantId,
subject_id: &'life2 SubjectId,
request_id: &'life3 RequestId,
locale: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<RequestContext, ContextError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Resolve a durable identity into a fresh context with current roles and entitlements.
Auto Trait Implementations§
impl Freeze for StaticContextProvider
impl RefUnwindSafe for StaticContextProvider
impl Send for StaticContextProvider
impl Sync for StaticContextProvider
impl Unpin for StaticContextProvider
impl UnsafeUnpin for StaticContextProvider
impl UnwindSafe for StaticContextProvider
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