Struct http::uri::PathAndQuery
source · [−]pub struct PathAndQuery { /* private fields */ }
Expand description
Represents the path component of a URI
Implementations
sourceimpl PathAndQuery
impl PathAndQuery
Attempt to convert a PathAndQuery
from Bytes
.
This function will be replaced by a TryFrom
implementation once the
trait lands in stable.
Examples
extern crate bytes;
use bytes::Bytes;
let bytes = Bytes::from("/hello?world");
let path_and_query = PathAndQuery::from_shared(bytes).unwrap();
assert_eq!(path_and_query.path(), "/hello");
assert_eq!(path_and_query.query(), Some("world"));
sourcepub fn from_static(src: &'static str) -> Self
pub fn from_static(src: &'static str) -> Self
Convert a PathAndQuery
from a static string.
This function will not perform any copying, however the string is checked to ensure that it is valid.
Panics
This function panics if the argument is an invalid path and query.
Examples
let v = PathAndQuery::from_static("/hello?world");
assert_eq!(v.path(), "/hello");
assert_eq!(v.query(), Some("world"));
sourcepub fn path(&self) -> &str
pub fn path(&self) -> &str
Returns the path component
The path component is case sensitive.
abc://username:password@example.com:123/path/data?key=value&key2=value2#fragid1
|--------|
|
path
If the URI is *
then the path component is equal to *
.
Examples
let path_and_query: PathAndQuery = "/hello/world".parse().unwrap();
assert_eq!(path_and_query.path(), "/hello/world");
sourcepub fn query(&self) -> Option<&str>
pub fn query(&self) -> Option<&str>
Returns the query string component
The query component contains non-hierarchical data that, along with data in the path component, serves to identify a resource within the scope of the URI’s scheme and naming authority (if any). The query component is indicated by the first question mark (“?”) character and terminated by a number sign (“#”) character or by the end of the URI.
abc://username:password@example.com:123/path/data?key=value&key2=value2#fragid1
|-------------------|
|
query
Examples
With a query string component
let path_and_query: PathAndQuery = "/hello/world?key=value&foo=bar".parse().unwrap();
assert_eq!(path_and_query.query(), Some("key=value&foo=bar"));
Without a query string component
let path_and_query: PathAndQuery = "/hello/world".parse().unwrap();
assert!(path_and_query.query().is_none());
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the path and query as a string component.
Examples
With a query string component
let path_and_query: PathAndQuery = "/hello/world?key=value&foo=bar".parse().unwrap();
assert_eq!(path_and_query.as_str(), "/hello/world?key=value&foo=bar");
Without a query string component
let path_and_query: PathAndQuery = "/hello/world".parse().unwrap();
assert_eq!(path_and_query.as_str(), "/hello/world");
sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Converts this PathAndQuery
back to a sequence of bytes
Trait Implementations
sourceimpl Clone for PathAndQuery
impl Clone for PathAndQuery
sourcefn clone(&self) -> PathAndQuery
fn clone(&self) -> PathAndQuery
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PathAndQuery
impl Debug for PathAndQuery
sourceimpl Display for PathAndQuery
impl Display for PathAndQuery
sourceimpl From<PathAndQuery> for Bytes
impl From<PathAndQuery> for Bytes
sourcefn from(src: PathAndQuery) -> Bytes
fn from(src: PathAndQuery) -> Bytes
Performs the conversion.
sourceimpl FromStr for PathAndQuery
impl FromStr for PathAndQuery
type Err = InvalidUri
type Err = InvalidUri
The associated error which can be returned from parsing.
sourceimpl<'a> HttpTryFrom<&'a [u8]> for PathAndQuery
impl<'a> HttpTryFrom<&'a [u8]> for PathAndQuery
type Error = InvalidUri
type Error = InvalidUri
Associated error with the conversion this implementation represents.
sourceimpl<'a> HttpTryFrom<&'a str> for PathAndQuery
impl<'a> HttpTryFrom<&'a str> for PathAndQuery
type Error = InvalidUri
type Error = InvalidUri
Associated error with the conversion this implementation represents.
sourceimpl HttpTryFrom<Bytes> for PathAndQuery
impl HttpTryFrom<Bytes> for PathAndQuery
type Error = InvalidUriBytes
type Error = InvalidUriBytes
Associated error with the conversion this implementation represents.
sourceimpl HttpTryFrom<PathAndQuery> for PathAndQuery
impl HttpTryFrom<PathAndQuery> for PathAndQuery
sourceimpl<'a> PartialEq<&'a str> for PathAndQuery
impl<'a> PartialEq<&'a str> for PathAndQuery
sourceimpl PartialEq<PathAndQuery> for PathAndQuery
impl PartialEq<PathAndQuery> for PathAndQuery
sourceimpl<'a> PartialEq<PathAndQuery> for &'a str
impl<'a> PartialEq<PathAndQuery> for &'a str
sourceimpl PartialEq<PathAndQuery> for str
impl PartialEq<PathAndQuery> for str
sourceimpl PartialEq<PathAndQuery> for String
impl PartialEq<PathAndQuery> for String
sourceimpl PartialEq<String> for PathAndQuery
impl PartialEq<String> for PathAndQuery
sourceimpl PartialEq<str> for PathAndQuery
impl PartialEq<str> for PathAndQuery
sourceimpl<'a> PartialOrd<&'a str> for PathAndQuery
impl<'a> PartialOrd<&'a str> for PathAndQuery
sourcefn partial_cmp(&self, other: &&'a str) -> Option<Ordering>
fn partial_cmp(&self, other: &&'a str) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<PathAndQuery> for PathAndQuery
impl PartialOrd<PathAndQuery> for PathAndQuery
sourcefn partial_cmp(&self, other: &PathAndQuery) -> Option<Ordering>
fn partial_cmp(&self, other: &PathAndQuery) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<PathAndQuery> for str
impl PartialOrd<PathAndQuery> for str
sourcefn partial_cmp(&self, other: &PathAndQuery) -> Option<Ordering>
fn partial_cmp(&self, other: &PathAndQuery) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<'a> PartialOrd<PathAndQuery> for &'a str
impl<'a> PartialOrd<PathAndQuery> for &'a str
sourcefn partial_cmp(&self, other: &PathAndQuery) -> Option<Ordering>
fn partial_cmp(&self, other: &PathAndQuery) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<PathAndQuery> for String
impl PartialOrd<PathAndQuery> for String
sourcefn partial_cmp(&self, other: &PathAndQuery) -> Option<Ordering>
fn partial_cmp(&self, other: &PathAndQuery) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<String> for PathAndQuery
impl PartialOrd<String> for PathAndQuery
sourcefn partial_cmp(&self, other: &String) -> Option<Ordering>
fn partial_cmp(&self, other: &String) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<str> for PathAndQuery
impl PartialOrd<str> for PathAndQuery
sourcefn partial_cmp(&self, other: &str) -> Option<Ordering>
fn partial_cmp(&self, other: &str) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for PathAndQuery
Auto Trait Implementations
impl RefUnwindSafe for PathAndQuery
impl Send for PathAndQuery
impl Sync for PathAndQuery
impl Unpin for PathAndQuery
impl UnwindSafe for PathAndQuery
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more