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.
Trait Implementations§
Source§impl Borrow<dyn QueryParameter + Send> for NormalizedParameter
impl Borrow<dyn QueryParameter + Send> for NormalizedParameter
Source§impl Borrow<dyn QueryParameter> for NormalizedParameter
impl Borrow<dyn QueryParameter> for NormalizedParameter
Source§fn borrow(&self) -> &(dyn QueryParameter + 'static)
fn borrow(&self) -> &(dyn QueryParameter + 'static)
Source§impl ToOwned for dyn QueryParameter
impl ToOwned for dyn QueryParameter
Source§type Owned = NormalizedParameter
type Owned = NormalizedParameter
Source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Source§impl ToOwned for dyn QueryParameter + Send
impl ToOwned for dyn QueryParameter + Send
Source§type Owned = NormalizedParameter
type Owned = NormalizedParameter
Source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".