Skip to main content

BindInput

Struct BindInput 

Source
pub struct BindInput<'a> {
    pub path: &'a HashMap<String, String>,
    pub query: &'a HashMap<String, String>,
    pub query_multi: Option<&'a HashMap<String, Vec<String>>>,
    pub claims: Option<&'a dyn IClaims>,
    pub form: Option<&'a MultipartForm>,
    pub is_body: bool,
    pub is_multipart: bool,
}
Expand description

The value providers a generated RequestModel::bind reads from.

Borrowed from the request context: binding never copies the route, query or header maps, and the form is shared through the request’s cached parse.

Fields§

§path: &'a HashMap<String, String>

Route parameters captured by the router ({} segments).

§query: &'a HashMap<String, String>

Query string, last value per key (the compatibility view).

§query_multi: Option<&'a HashMap<String, Vec<String>>>

Query string, every value per key; None when the host does not provide multi-value parsing.

§claims: Option<&'a dyn IClaims>

The authenticated principal, when the request is authenticated.

§form: Option<&'a MultipartForm>

The parsed multipart/form-data body, when the request is multipart.

§is_body: bool

Whether the route method is POST, PUT or PATCH.

§is_multipart: bool

Whether the request declares multipart/form-data.

Implementations§

Source§

impl<'a> BindInput<'a>

Source

pub fn path_one(&self, name: &str) -> Option<&'a str>

The route value for name.

Source

pub fn path_list(&self, name: &str) -> Vec<&'a str>

Every route value for name, comma-separated lists expanded.

A route segment is a single value, but {ids} accepting 1,2,3 is a convenient way to bind Vec<T> from the path — the same rule query values follow.

Source

pub fn query_one(&self, name: &str) -> Option<&'a str>

The last query value for name.

Source

pub fn query_list(&self, name: &str) -> Vec<&'a str>

Every query value for name, comma-separated lists expanded.

Source

pub fn form_one(&self, name: &str) -> Option<&'a str>

The first text part named name in the form.

Source

pub fn form_list(&self, name: &str) -> Vec<&'a str>

Every text part named name, comma-separated lists expanded.

Source

pub fn file(&self, name: &str) -> Option<&'a FormFile>

The first file part named name.

Source

pub fn files(&self, name: &str) -> Vec<&'a FormFile>

Every file part named name, in order.

Source

pub fn claim(&self, key: &str) -> Option<&'a str>

A claim value by key.

The raw claim map wins, so a token that literally carries user_id or tenant keeps that value. The dedicated accessors are only a fallback when the raw map has no such key: sub / subject resolve to the subject, tenant_id / tenant to the tenant helper.

Source

pub fn claim_list(&self, key: &str) -> Vec<&'a str>

A claim as a list: the raw claim map wins (comma-separated); roles / permissions fall back to their dedicated slots when the raw map has no such key.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for BindInput<'a>

§

impl<'a> !UnwindSafe for BindInput<'a>

§

impl<'a> Forget for BindInput<'a>

§

impl<'a> Freeze for BindInput<'a>

§

impl<'a> Send for BindInput<'a>

§

impl<'a> Sync for BindInput<'a>

§

impl<'a> Unpin for BindInput<'a>

§

impl<'a> UnsafeUnpin for BindInput<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more