Struct PathMut
pub struct PathMut<'a> { /* private fields */ }http only.Expand description
Mutable view of a Uri’s path component.
Holds the Owned representation of the URI for the guard’s lifetime. Each method modifies the path in place. Drop releases the borrow — no special finalization required.
Implementations§
§impl<'a> PathMut<'a>
impl<'a> PathMut<'a>
pub fn push_segment(
&mut self,
segment: impl IntoUriComponent,
) -> &mut PathMut<'a>
Available on crate feature net only.
pub fn push_segment( &mut self, segment: impl IntoUriComponent, ) -> &mut PathMut<'a>
net only.Append a /-delimited segment, percent-encoding any bytes that
aren’t legal in a URI path segment per RFC 3986.
Encodes: ASCII controls, space, ", #, %, /, <, >,
?, [, \, ], ^, `, {, |, }, and every
non-ASCII byte. Passes through: ALPHA, DIGIT, -._~,
!$&'()*+,;=, :, @. The % itself is encoded to %25 —
pass already-decoded values, not pre-encoded ones.
If the current path doesn’t already end with /, one is
inserted before the segment. Empty path + push_segment("x")
yields /x. /foo + push_segment("bar") yields /foo/bar.
/foo/ + push_segment("bar") yields /foo/bar (no double
slash).
pub fn pop_segment(&mut self) -> Option<BytesMut>
Available on crate feature net only.
pub fn pop_segment(&mut self) -> Option<BytesMut>
net only.Remove and return the last path segment.
/foo/bar → Some("bar"), path becomes /foo. /foo/ →
Some(""), path becomes /foo. /foo → Some("foo"), path
becomes empty. Empty path → None. Opaque paths (no /) → the
whole path is returned.
The returned bytes are the raw on-wire form (still
percent-encoded). Use PathSegment::as_decoded_str
on the corresponding PathRef::segments
item before mutation if you need the decoded value.
pub fn clear(&mut self) -> &mut PathMut<'a>
Available on crate feature net only.
pub fn clear(&mut self) -> &mut PathMut<'a>
net only.Clear the path entirely.
pub fn ensure_trailing_slash(&mut self) -> &mut PathMut<'a>
Available on crate feature net only.
pub fn ensure_trailing_slash(&mut self) -> &mut PathMut<'a>
net only.Ensure the path ends with exactly one trailing /: appended when
missing, left alone when already present. An empty path becomes /.
pub fn push_segments(
&mut self,
segments: impl IntoUriComponent,
) -> &mut PathMut<'a>
Available on crate feature net only.
pub fn push_segments( &mut self, segments: impl IntoUriComponent, ) -> &mut PathMut<'a>
net only.Append multiple /-delimited segments at once.
Splits the input on / and pushes each piece via
push_segment, so every piece is
percent-encoded under the path-segment policy (a literal /
inside the input is the separator, not encoded). The normal
slash-insertion rule applies, so "a/b" and "/a/b" both append
/a/b, internal // collapses to a single separator, and a
trailing / yields a trailing empty segment.
"/api" + push_segments("v2/users") → /api/v2/users.
pub fn pop_segments(&mut self, n: usize) -> usize
Available on crate feature net only.
pub fn pop_segments(&mut self, n: usize) -> usize
net only.Remove up to n trailing segments, returning the number actually
removed (fewer than n if the path runs out first).
Equivalent to calling pop_segment n
times, stopping early at an empty path.
pub fn strip_prefix(&mut self, prefix: impl IntoUriComponent) -> bool
Available on crate feature net only.
pub fn strip_prefix(&mut self, prefix: impl IntoUriComponent) -> bool
net only.Strip a leading prefix from the path, re-rooting the remainder with
a single leading /. Matching uses the default PathMatchOptions
(segment-boundary, percent-decoded, case-sensitive); see
strip_prefix_with_opts to allow
partial / raw / case-insensitive matching.
Returns true when the prefix matched and was removed; otherwise the
path is left unchanged and false is returned.
pub fn strip_prefix_with_opts(
&mut self,
prefix: impl IntoUriComponent,
opts: PathMatchOptions,
) -> bool
Available on crate feature net only.
pub fn strip_prefix_with_opts( &mut self, prefix: impl IntoUriComponent, opts: PathMatchOptions, ) -> bool
net only.strip_prefix with explicit PathMatchOptions.
pub fn strip_suffix(&mut self, suffix: impl IntoUriComponent) -> bool
Available on crate feature net only.
pub fn strip_suffix(&mut self, suffix: impl IntoUriComponent) -> bool
net only.Strip a trailing suffix from the path, keeping a single leading /.
Matching uses the default PathMatchOptions; see
strip_suffix_with_opts for the rest.
Returns true when the suffix matched and was removed.
pub fn strip_suffix_with_opts(
&mut self,
suffix: impl IntoUriComponent,
opts: PathMatchOptions,
) -> bool
Available on crate feature net only.
pub fn strip_suffix_with_opts( &mut self, suffix: impl IntoUriComponent, opts: PathMatchOptions, ) -> bool
net only.strip_suffix with explicit PathMatchOptions.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !UnwindSafe for PathMut<'a>
impl<'a> Freeze for PathMut<'a>
impl<'a> RefUnwindSafe for PathMut<'a>
impl<'a> Send for PathMut<'a>
impl<'a> Sync for PathMut<'a>
impl<'a> Unpin for PathMut<'a>
impl<'a> UnsafeUnpin for PathMut<'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
§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<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