Skip to main content

ExtractedParams

Struct ExtractedParams 

Source
pub struct ExtractedParams { /* private fields */ }
Expand description

Parameters extracted after route resolution — path captures plus the declared query and body values. The #[controller] macro reads typed handler arguments out of this; application code rarely touches it directly.

Implementations§

Source§

impl ExtractedParams

Source

pub fn get_string(&self, name: &str) -> Result<String, WebError>

The value of path/query parameter name as a String; 400 if absent.

Source

pub fn get_i64(&self, name: &str) -> Result<i64, WebError>

Parse path/query parameter name as an i64; 400 if missing or unparsable.

Source

pub fn get_u64(&self, name: &str) -> Result<u64, WebError>

Parse path/query parameter name as a u64; 400 if missing or unparsable.

Source

pub fn get_u32(&self, name: &str) -> Result<u32, WebError>

Parse path/query parameter name as a u32; 400 if missing or unparsable.

Source

pub fn get_f64(&self, name: &str) -> Result<f64, WebError>

Parse path/query parameter name as an f64; 400 if missing or unparsable.

Source

pub fn get_bool(&self, name: &str) -> Result<bool, WebError>

Read path/query parameter name as a bool — false for an empty value, "false" or "0"; true otherwise. 400 when absent, exactly as get_string / get_i64 / every other scalar getter, all of which go through require_scalar.

It did NOT always do that, and the history is the point. It used to answer Ok(false) for a missing parameter — the one getter that invented a value instead of erroring. The generated default is get_x(name).unwrap_or(default), which relies on that Err, so this method swallowed the absence and every param: bool = true silently behaved as false.

⚠️ Found in a consumer, 2026-09-04: a cancellation route declared at_period_end: bool = true and documented the reversible, deferred form as its default. A client that omitted the parameter got the immediate cancellation instead — the destructive direction, and the opposite of what the route promised. It stayed invisible because the route behaved correctly whenever the parameter was supplied.

⇒ Use Self::get_bool_optional when you need to tell an absent parameter from an explicit false; that is what a declared default reads.

⚠️ Correction, 2026-09-04. This doc used to justify the old unwrap_or(false) by saying a bare param: bool means “false unless asked for” (confirm, dry_run) and that erroring on absence would turn those into 400s. That was false and was never checked: a bare bool already 400s, because routing::param_is_required reports it required and resolve rejects the request before extraction runs. An optional flag is written confirm: bool = false. The fallback was the last code in the crate asserting the opposite of what the router does, so it is gone — nothing outside this crate could reach it, since ExtractedParams has no public constructor and resolve is the only way to obtain one.

Source

pub fn get_bool_optional(&self, name: &str) -> Result<Option<bool>, WebError>

Like Self::get_bool, but distinguishes absent (None) from the value false — the reader a declared default needs.

⭐ This exists because bool is the only parameter type where “not supplied” and “supplied as the falsy value” are both meaningful. For every other type the absence is already an Err and the default falls out of unwrap_or; here it has to be asked for explicitly.

The _optional name is the crate’s convention for exactly this pair — see Params::get_bool_optional, which draws the same distinction on the pre-resolution type. (This one returns Result because every ExtractedParams getter does; it has no failure case of its own.)

Source

pub fn get_string_array(&self, name: &str) -> Result<Vec<String>, WebError>

All values for name (in request order; empty if the name wasn’t present). Backs Vec<String> handler parameters — a one-element list (?tags=a) and a many-element one (?tags=a&tags=b) flow through the same path.

Source

pub fn get_json_body(&self) -> Result<JsonValue, WebError>

The parsed JSON request body, or 400 Bad Request if there wasn’t one.

Source

pub fn get_body_bytes(&self) -> Bytes

Raw bytes of the request body. See Params::body_bytes for the content-type-aware semantics. Used by the macro to extract a Bytes handler argument.

Trait Implementations§

Source§

impl Debug for ExtractedParams

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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