pub struct PathAndQuery { /* private fields */ }Expand description
Represents the path component of a URI
Implementations§
Source§impl PathAndQuery
impl PathAndQuery
Sourcepub fn from_static(src: &'static str) -> PathAndQuery
pub fn from_static(src: &'static str) -> PathAndQuery
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"));Attempt to convert a Bytes buffer to a PathAndQuery.
This will try to prevent a copy if the type passed is the type used internally, and will copy the data if it is not.
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
|--------|
|
pathIf 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");Trait Implementations§
Source§impl Clone for PathAndQuery
impl Clone for PathAndQuery
Source§fn clone(&self) -> PathAndQuery
fn clone(&self) -> PathAndQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PathAndQuery
impl Debug for PathAndQuery
Source§impl Display for PathAndQuery
impl Display for PathAndQuery
Source§impl From<PathAndQuery> for Uri
Convert a PathAndQuery into a Uri.
impl From<PathAndQuery> for Uri
Convert a PathAndQuery into a Uri.
Source§fn from(path_and_query: PathAndQuery) -> Uri
fn from(path_and_query: PathAndQuery) -> Uri
Source§impl FromStr for PathAndQuery
impl FromStr for PathAndQuery
Source§type Err = InvalidUri
type Err = InvalidUri
Source§fn from_str(s: &str) -> Result<PathAndQuery, InvalidUri>
fn from_str(s: &str) -> Result<PathAndQuery, InvalidUri>
s to return a value of this type. Read moreSource§impl Hash for PathAndQuery
impl Hash for PathAndQuery
Source§impl<'a> PartialEq<&'a str> for PathAndQuery
impl<'a> PartialEq<&'a str> for PathAndQuery
Source§impl<'a> PartialEq<PathAndQuery> for &'a str
impl<'a> PartialEq<PathAndQuery> for &'a str
Source§impl PartialEq<PathAndQuery> for String
impl PartialEq<PathAndQuery> for String
Source§impl PartialEq<PathAndQuery> for str
impl PartialEq<PathAndQuery> for str
Source§impl PartialEq<String> for PathAndQuery
impl PartialEq<String> for PathAndQuery
Source§impl PartialEq<str> for PathAndQuery
impl PartialEq<str> for PathAndQuery
Source§impl PartialEq for PathAndQuery
impl PartialEq for PathAndQuery
Source§impl<'a> PartialOrd<&'a str> for PathAndQuery
impl<'a> PartialOrd<&'a str> for PathAndQuery
Source§impl<'a> PartialOrd<PathAndQuery> for &'a str
impl<'a> PartialOrd<PathAndQuery> for &'a str
Source§impl PartialOrd<PathAndQuery> for String
impl PartialOrd<PathAndQuery> for String
Source§impl PartialOrd<PathAndQuery> for str
impl PartialOrd<PathAndQuery> for str
Source§impl PartialOrd<String> for PathAndQuery
impl PartialOrd<String> for PathAndQuery
Source§impl PartialOrd<str> for PathAndQuery
impl PartialOrd<str> for PathAndQuery
Source§impl PartialOrd for PathAndQuery
impl PartialOrd for PathAndQuery
Source§impl<'a> TryFrom<&'a [u8]> for PathAndQuery
impl<'a> TryFrom<&'a [u8]> for PathAndQuery
Source§type Error = InvalidUri
type Error = InvalidUri
Source§fn try_from(
s: &'a [u8],
) -> Result<PathAndQuery, <PathAndQuery as TryFrom<&'a [u8]>>::Error>
fn try_from( s: &'a [u8], ) -> Result<PathAndQuery, <PathAndQuery as TryFrom<&'a [u8]>>::Error>
Source§impl TryFrom<&String> for PathAndQuery
impl TryFrom<&String> for PathAndQuery
Source§type Error = InvalidUri
type Error = InvalidUri
Source§fn try_from(
s: &String,
) -> Result<PathAndQuery, <PathAndQuery as TryFrom<&String>>::Error>
fn try_from( s: &String, ) -> Result<PathAndQuery, <PathAndQuery as TryFrom<&String>>::Error>
Source§impl<'a> TryFrom<&'a str> for PathAndQuery
impl<'a> TryFrom<&'a str> for PathAndQuery
Source§type Error = InvalidUri
type Error = InvalidUri
Source§fn try_from(
s: &'a str,
) -> Result<PathAndQuery, <PathAndQuery as TryFrom<&'a str>>::Error>
fn try_from( s: &'a str, ) -> Result<PathAndQuery, <PathAndQuery as TryFrom<&'a str>>::Error>
Source§impl TryFrom<String> for PathAndQuery
impl TryFrom<String> for PathAndQuery
Source§type Error = InvalidUri
type Error = InvalidUri
Source§fn try_from(
s: String,
) -> Result<PathAndQuery, <PathAndQuery as TryFrom<String>>::Error>
fn try_from( s: String, ) -> Result<PathAndQuery, <PathAndQuery as TryFrom<String>>::Error>
impl Eq for PathAndQuery
Auto Trait Implementations§
impl !Freeze for PathAndQuery
impl RefUnwindSafe for PathAndQuery
impl Send for PathAndQuery
impl Sync for PathAndQuery
impl Unpin for PathAndQuery
impl UnwindSafe for PathAndQuery
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DataNoteValue for T
impl<T> DataNoteValue for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Separable for Twhere
T: Display,
impl<T> Separable for Twhere
T: Display,
Source§fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
SeparatorPolicy. Read more