Skip to main content

Secured

Struct Secured 

Source
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 references
  • C - The client type being wrapped

Implementations§

Source§

impl<'a, C> Secured<'a, C>

Source

pub fn new(client: &'a C, ctx: &'a SecurityContext) -> Self

Creates a new Secured wrapper binding a client and security context.

§Arguments
  • client - Reference to the client
  • ctx - Reference to the security context
§Example
let secured = Secured::new(&client, &ctx);
Source

pub fn client(&self) -> &'a C

Returns a reference to the wrapped client.

§Example
let client_ref = secured.client();
Source

pub fn ctx(&self) -> &'a SecurityContext

Returns a reference to the security context.

§Example
let ctx_ref = secured.ctx();
let tenant_id = ctx_ref.subject_tenant_id();
Source

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§

Source§

impl<C> Clone for Secured<'_, C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, C: Debug> Debug for Secured<'a, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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> UnsafeUnpin for Secured<'a, C>

§

impl<'a, C> UnwindSafe for Secured<'a, C>
where C: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSecurityContext for T

Source§

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