[][src]Struct uriparse::query::Query

pub struct Query<'query> { /* fields omitted */ }

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]

type Target = str

The resulting type after dereferencing.

impl<'_> Display for Query<'_>[src]

impl<'_> Eq for Query<'_>[src]

impl<'query> From<Query<'query>> for String[src]

impl<'_> Hash for Query<'_>[src]

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]

impl<'a, 'query> PartialEq<Query<'query>> for &'a [u8][src]

impl<'query> PartialEq<Query<'query>> for str[src]

impl<'a, 'query> PartialEq<Query<'query>> for &'a str[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.

impl<'query> TryFrom<&'query str> for Query<'query>[src]

type Error = QueryError

The type returned in the event of a conversion error.

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.