Struct PathSegment
pub struct PathSegment<'a> { /* private fields */ }net only.Expand description
One segment in a URI path — the bytes between two / separators
(or between a / and the end of the path).
Use PathSegment::as_encoded_str or PathSegment::as_decoded_str to
explicitly choose a presentation.
Implementations§
§impl<'a> PathSegment<'a>
impl<'a> PathSegment<'a>
pub fn as_encoded_str(self) -> Cow<'a, str>
pub fn as_encoded_str(self) -> Cow<'a, str>
Percent-encoded segment.
Cow::Borrowed when the segment does not have to be encoded.
pub fn as_decoded_str(self) -> Cow<'a, str>
pub fn as_decoded_str(self) -> Cow<'a, str>
Percent-decoded segment.
Cow::Borrowed when the segment contains no %; Cow::Owned
when decoding actually changed bytes. UTF-8 errors in the
decoded result fall back to the Unicode replacement character
(matches what curl and browsers do).
pub fn is_empty(self) -> bool
pub fn is_empty(self) -> bool
true if this segment is empty (""). Useful for detecting
trailing slashes and double-slashes.
pub fn matches(self, other: impl IntoUriComponent) -> bool
pub fn matches(self, other: impl IntoUriComponent) -> bool
true when this segment equals other, comparing percent-decoded
values (default PathMatchOptions). The typed alternative to
seg.as_decoded_str() == other that also handles %-case and the
invalid-UTF-8 pitfalls correctly.
pub fn matches_with_opts(
self,
other: impl IntoUriComponent,
opts: PathMatchOptions,
) -> bool
pub fn matches_with_opts( self, other: impl IntoUriComponent, opts: PathMatchOptions, ) -> bool
true when this segment equals other under opts (the partial
flag is irrelevant within a single segment and is ignored here).
pub fn has_prefix(self, prefix: impl IntoUriComponent) -> bool
pub fn has_prefix(self, prefix: impl IntoUriComponent) -> bool
true when the (percent-decoded) segment value begins with prefix.
Byte-level within this one segment — for e.g. file-name prefixes.
pub fn has_prefix_with_opts(
self,
prefix: impl IntoUriComponent,
opts: PathMatchOptions,
) -> bool
pub fn has_prefix_with_opts( self, prefix: impl IntoUriComponent, opts: PathMatchOptions, ) -> bool
true when the (percent-decoded) segment value begins with prefix
under opts (partial ignored — always byte-level within the segment).
pub fn has_suffix(self, suffix: impl IntoUriComponent) -> bool
pub fn has_suffix(self, suffix: impl IntoUriComponent) -> bool
true when the (percent-decoded) segment value ends with suffix.
Byte-level within this one segment — e.g. a file extension:
seg.has_suffix(".tgz").
pub fn has_suffix_with_opts(
self,
suffix: impl IntoUriComponent,
opts: PathMatchOptions,
) -> bool
pub fn has_suffix_with_opts( self, suffix: impl IntoUriComponent, opts: PathMatchOptions, ) -> bool
true when the (percent-decoded) segment value ends with suffix
under opts (partial ignored — always byte-level within the segment).
Trait Implementations§
§impl<'a> Clone for PathSegment<'a>
impl<'a> Clone for PathSegment<'a>
§fn clone(&self) -> PathSegment<'a>
fn clone(&self) -> PathSegment<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for PathSegment<'a>
§impl<'a> Debug for PathSegment<'a>
impl<'a> Debug for PathSegment<'a>
§impl Display for PathSegment<'_>
impl Display for PathSegment<'_>
impl Eq for PathSegment<'_>
§impl Hash for PathSegment<'_>
impl Hash for PathSegment<'_>
impl IntoUriComponent for PathSegment<'_>
§impl Ord for PathSegment<'_>
impl Ord for PathSegment<'_>
§fn cmp(&self, other: &PathSegment<'_>) -> Ordering
fn cmp(&self, other: &PathSegment<'_>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialEq for PathSegment<'_>
impl PartialEq for PathSegment<'_>
§impl PartialEq<&str> for PathSegment<'_>
impl PartialEq<&str> for PathSegment<'_>
§impl<'a> PartialEq<PathSegment<'a>> for str
impl<'a> PartialEq<PathSegment<'a>> for str
§impl<'a> PartialEq<PathSegment<'a>> for &str
impl<'a> PartialEq<PathSegment<'a>> for &str
§impl PartialEq<str> for PathSegment<'_>
impl PartialEq<str> for PathSegment<'_>
§impl PartialOrd for PathSegment<'_>
impl PartialOrd for PathSegment<'_>
Auto Trait Implementations§
impl<'a> Freeze for PathSegment<'a>
impl<'a> RefUnwindSafe for PathSegment<'a>
impl<'a> Send for PathSegment<'a>
impl<'a> Sync for PathSegment<'a>
impl<'a> Unpin for PathSegment<'a>
impl<'a> UnsafeUnpin for PathSegment<'a>
impl<'a> UnwindSafe for PathSegment<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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<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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§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> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§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.
§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writer§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writer§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writer§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writer§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer