[][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.

Methods

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<'_> PartialEq<Query<'_>> for Query<'_>[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<'_> PartialEq<[u8]> for Query<'_>[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<'a, '_> PartialEq<&'a str> for Query<'_>[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

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

impl<'query> Clone for Query<'query>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

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

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

impl<'query> Debug for Query<'query>[src]

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

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

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

type Target = str

The resulting type after dereferencing.

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

type Error = InvalidQuery

The type returned in the event of a conversion error.

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

type Error = InvalidQuery

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'query> Send for Query<'query>

impl<'query> Sync for Query<'query>

Blanket Implementations

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

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

type Owned = T

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]