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
impl ExtractedParams
Sourcepub fn get_string(&self, name: &str) -> Result<String, WebError>
pub fn get_string(&self, name: &str) -> Result<String, WebError>
The value of path/query parameter name as a String; 400 if absent.
Sourcepub fn get_i64(&self, name: &str) -> Result<i64, WebError>
pub fn get_i64(&self, name: &str) -> Result<i64, WebError>
Parse path/query parameter name as an i64; 400 if missing or
unparsable.
Sourcepub fn get_u64(&self, name: &str) -> Result<u64, WebError>
pub fn get_u64(&self, name: &str) -> Result<u64, WebError>
Parse path/query parameter name as a u64; 400 if missing or
unparsable.
Sourcepub fn get_u32(&self, name: &str) -> Result<u32, WebError>
pub fn get_u32(&self, name: &str) -> Result<u32, WebError>
Parse path/query parameter name as a u32; 400 if missing or
unparsable.
Sourcepub fn get_f64(&self, name: &str) -> Result<f64, WebError>
pub fn get_f64(&self, name: &str) -> Result<f64, WebError>
Parse path/query parameter name as an f64; 400 if missing or
unparsable.
Sourcepub fn get_bool(&self, name: &str) -> Result<bool, WebError>
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.
Sourcepub fn get_bool_optional(&self, name: &str) -> Result<Option<bool>, WebError>
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.)
Sourcepub fn get_string_array(&self, name: &str) -> Result<Vec<String>, WebError>
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.
Sourcepub fn get_json_body(&self) -> Result<JsonValue, WebError>
pub fn get_json_body(&self) -> Result<JsonValue, WebError>
The parsed JSON request body, or 400 Bad Request if there wasn’t one.
Sourcepub fn get_body_bytes(&self) -> Bytes
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.