Struct PathAndQuery
pub struct PathAndQuery { /* private fields */ }Expand description
Represents the path component of a URI
Implementations§
§impl PathAndQuery
impl PathAndQuery
pub 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.
pub 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");pub 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());pub 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§
§impl Clone for PathAndQuery
impl Clone for PathAndQuery
§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 more§impl Debug for PathAndQuery
impl Debug for PathAndQuery
§impl Display for PathAndQuery
impl Display for PathAndQuery
§impl From<PathAndQuery> for Uri
Convert a PathAndQuery into a Uri.
impl From<PathAndQuery> for Uri
Convert a PathAndQuery into a Uri.
§fn from(path_and_query: PathAndQuery) -> Uri
fn from(path_and_query: PathAndQuery) -> Uri
§impl FromStr for PathAndQuery
impl FromStr for PathAndQuery
§type Err = InvalidUri
type Err = InvalidUri
§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 more§impl Hash for PathAndQuery
impl Hash for PathAndQuery
§impl<'a> PartialEq<&'a str> for PathAndQuery
impl<'a> PartialEq<&'a str> for PathAndQuery
§impl<'a> PartialEq<PathAndQuery> for &'a str
impl<'a> PartialEq<PathAndQuery> for &'a str
§impl PartialEq<PathAndQuery> for String
impl PartialEq<PathAndQuery> for String
§impl PartialEq<PathAndQuery> for str
impl PartialEq<PathAndQuery> for str
§impl PartialEq<String> for PathAndQuery
impl PartialEq<String> for PathAndQuery
§impl PartialEq<str> for PathAndQuery
impl PartialEq<str> for PathAndQuery
§impl PartialEq for PathAndQuery
impl PartialEq for PathAndQuery
§impl<'a> PartialOrd<&'a str> for PathAndQuery
impl<'a> PartialOrd<&'a str> for PathAndQuery
§impl<'a> PartialOrd<PathAndQuery> for &'a str
impl<'a> PartialOrd<PathAndQuery> for &'a str
§impl PartialOrd<PathAndQuery> for String
impl PartialOrd<PathAndQuery> for String
§impl PartialOrd<PathAndQuery> for str
impl PartialOrd<PathAndQuery> for str
§impl PartialOrd<String> for PathAndQuery
impl PartialOrd<String> for PathAndQuery
§impl PartialOrd<str> for PathAndQuery
impl PartialOrd<str> for PathAndQuery
§impl PartialOrd for PathAndQuery
impl PartialOrd for PathAndQuery
§impl<'a> TryFrom<&'a [u8]> for PathAndQuery
impl<'a> TryFrom<&'a [u8]> for PathAndQuery
§type Error = InvalidUri
type Error = InvalidUri
§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>
§impl TryFrom<&String> for PathAndQuery
impl TryFrom<&String> for PathAndQuery
§type Error = InvalidUri
type Error = InvalidUri
§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<'a> TryFrom<&'a str> for PathAndQuery
impl<'a> TryFrom<&'a str> for PathAndQuery
§type Error = InvalidUri
type Error = InvalidUri
§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>
§impl TryFrom<String> for PathAndQuery
impl TryFrom<String> for PathAndQuery
§type Error = InvalidUri
type Error = InvalidUri
§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 TryFrom<Vec<u8>> for PathAndQuery
impl TryFrom<Vec<u8>> for PathAndQuery
§type Error = InvalidUri
type Error = InvalidUri
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§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> 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
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
§impl<T> ToSmolStr for T
impl<T> ToSmolStr for T
fn to_smolstr(&self) -> SmolStr
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.