[−][src]Struct uriparse::query::Query
The query component as defined in [RFC3986, Section 3.4].
The query is case-sensitive. Furthermore, percent-encoding plays no role in equality checking
for characters in the unreserved character set meaning that "query"
and "que%72y"
are
identical. Both of these attributes are reflected in the equality and hash functions.
However, be aware that just because percent-encoding plays no role in equality checking does not
mean that the query is normalized. If the query needs to be normalized, use the
Query::normalize
function.
Implementations
impl<'_> Query<'_>
[src]
pub fn as_borrowed(&self) -> Query<'_>
[src]
Returns a new query which is identical but has a lifetime tied to this query.
pub fn as_str(&self) -> &str
[src]
Returns a str
representation of the query.
Examples
use std::convert::TryFrom; use uriparse::Query; let query = Query::try_from("query").unwrap(); assert_eq!(query.as_str(), "query");
pub fn into_owned(self) -> Query<'static>
[src]
Converts the Query
into an owned copy.
If you construct the query from a source with a non-static lifetime, you may run into lifetime problems due to the way the struct is designed. Calling this function will ensure that the returned value has a static lifetime.
This is different from just cloning. Cloning the query will just copy the references, and thus the lifetime will remain the same.
pub fn is_normalized(&self) -> bool
[src]
Returns whether the query is normalized.
A normalized query will have no bytes that are in the unreserved character set percent-encoded and all alphabetical characters in percent-encodings will be uppercase.
This function runs in constant-time.
Examples
use std::convert::TryFrom; use uriparse::Query; let query = Query::try_from("query").unwrap(); assert!(query.is_normalized()); let mut query = Query::try_from("%ff%ff").unwrap(); assert!(!query.is_normalized()); query.normalize(); assert!(query.is_normalized());
pub fn normalize(&mut self)
[src]
Normalizes the query such that it will have no bytes that are in the unreserved character set percent-encoded and all alphabetical characters in percent-encodings will be uppercase.
If the query is already normalized, the function will return immediately. Otherwise, if the query is not owned, this function will perform an allocation to clone it. The normalization itself though, is done in-place with no extra memory allocations required.
Examples
use std::convert::TryFrom; use uriparse::Query; let mut query = Query::try_from("query").unwrap(); query.normalize(); assert_eq!(query, "query"); let mut query = Query::try_from("%ff%41").unwrap(); assert_eq!(query, "%ff%41"); query.normalize(); assert_eq!(query, "%FFA");
Trait Implementations
impl<'_> AsRef<[u8]> for Query<'_>
[src]
impl<'_> AsRef<str> for Query<'_>
[src]
impl<'query> Clone for Query<'query>
[src]
impl<'query> Debug for Query<'query>
[src]
impl<'_> Deref for Query<'_>
[src]
impl<'_> Display for Query<'_>
[src]
impl<'_> Eq for Query<'_>
[src]
impl<'query> From<Query<'query>> for String
[src]
impl<'_> Hash for Query<'_>
[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, '_> PartialEq<&'a [u8]> for Query<'_>
[src]
impl<'a, '_> PartialEq<&'a str> for Query<'_>
[src]
impl<'_> PartialEq<[u8]> for Query<'_>
[src]
impl<'_> PartialEq<Query<'_>> for Query<'_>
[src]
impl<'query> PartialEq<Query<'query>> for [u8]
[src]
fn eq(&self, other: &Query<'query>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'query> PartialEq<Query<'query>> for &'a [u8]
[src]
fn eq(&self, other: &Query<'query>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'query> PartialEq<Query<'query>> for str
[src]
fn eq(&self, other: &Query<'query>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'query> PartialEq<Query<'query>> for &'a str
[src]
fn eq(&self, other: &Query<'query>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<str> for Query<'_>
[src]
impl<'query> TryFrom<&'query [u8]> for Query<'query>
[src]
type Error = QueryError
The type returned in the event of a conversion error.
fn try_from(value: &'query [u8]) -> Result<Self, Self::Error>
[src]
impl<'query> TryFrom<&'query str> for Query<'query>
[src]
Auto Trait Implementations
impl<'query> RefUnwindSafe for Query<'query>
impl<'query> Send for Query<'query>
impl<'query> Sync for Query<'query>
impl<'query> Unpin for Query<'query>
impl<'query> UnwindSafe for Query<'query>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,