pub struct Secured<'a, C> { /* private fields */ }Expand description
A wrapper that binds a SecurityContext to a client reference.
This struct provides a zero-cost abstraction for carrying both a client and its associated security context together, without any allocation or cloning.
§Type Parameters
'a- The lifetime of both the client and security context referencesC- The client type being wrapped
Implementations§
Source§impl<'a, C> Secured<'a, C>
impl<'a, C> Secured<'a, C>
Sourcepub fn new(client: &'a C, ctx: &'a SecurityContext) -> Self
pub fn new(client: &'a C, ctx: &'a SecurityContext) -> Self
Sourcepub fn ctx(&self) -> &'a SecurityContext
pub fn ctx(&self) -> &'a SecurityContext
Sourcepub fn query<S: Schema>(&self) -> QueryBuilder<S>
pub fn query<S: Schema>(&self) -> QueryBuilder<S>
Create a new query builder for the given schema.
This provides an ergonomic entrypoint for building queries from a secured client.
§Example
ⓘ
use modkit_sdk::odata::items_stream;
let items = items_stream(
client.security_ctx(&ctx)
.query::<UserSchema>()
.filter(user::email().contains("@example.com")),
|query| async move { client.list_users(query).await },
);Trait Implementations§
impl<C> Copy for Secured<'_, C>
Auto Trait Implementations§
impl<'a, C> Freeze for Secured<'a, C>
impl<'a, C> RefUnwindSafe for Secured<'a, C>where
C: RefUnwindSafe,
impl<'a, C> Send for Secured<'a, C>where
C: Sync,
impl<'a, C> Sync for Secured<'a, C>where
C: Sync,
impl<'a, C> Unpin for Secured<'a, C>
impl<'a, C> UnwindSafe for Secured<'a, C>where
C: RefUnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> WithSecurityContext for T
impl<T> WithSecurityContext for T
Source§fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, T>
fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, T>
Binds a security context to this client, returning a
Secured wrapper. Read more