pub unsafe trait QueryParameter {
// Required methods
fn unique_value(&self, key: &str) -> Option<Cow<'_, str>>;
fn normalize(&self) -> NormalizedParameter;
}Expand description
Allows access to the query parameters in an url or a body.
Use one of the listed implementations below. Since those may be a bit confusing due to their
abundant use of generics, basically use any type of HashMap that maps ‘str-likes’ to a
collection of other ‘str-likes’. Popular instances may be:
HashMap<String, String>HashMap<String, Vec<String>>HashMap<Cow<'static, str>, Cow<'static, str>>
You should generally not have to implement this trait yourself, and if you do there are
additional requirements on your implementation to guarantee standard conformance. Therefore the
trait is marked as unsafe.
Required Methods§
Sourcefn unique_value(&self, key: &str) -> Option<Cow<'_, str>>
fn unique_value(&self, key: &str) -> Option<Cow<'_, str>>
Get the unique value associated with a key.
If there are multiple values, return None. This is very important to guarantee
conformance to the RFC. Afaik it prevents potentially subverting validation middleware,
order dependent processing, or simple confusion between different components who parse the
query string from different ends.
Sourcefn normalize(&self) -> NormalizedParameter
fn normalize(&self) -> NormalizedParameter
Guarantees that one can grab an owned copy.