Skip to main content

ResolvedPath

Struct ResolvedPath 

Source
pub struct ResolvedPath<'a>(/* private fields */);
Expand description

A request path that has already been fully resolved and checked.

§What the value guarantees

Every value of this type was produced by ResolvedPath::from_checked, which is the only constructor. So, for any ResolvedPath an implementor receives:

  • Every ${var} template-literal interpolation (LAYER 1) and every {key} placeholder (LAYER 2) has already been substituted. There is nothing left to resolve and an implementor must not attempt its own placeholder resolution.
  • Each substituted contribution passed validate_path_placeholder where it was produced.
  • The COMPOSED string passed validate_resolved_path — so it carries no parent-directory sequence, no residual {/}, no #, no backslash, no ASCII control byte, no over-cap segment and no empty interior segment, on EITHER side of an author-written ?. None of those is visible to a per-value check, because a composition belongs to no single value.
  • At most one ?, and only one an author wrote into a PathPart::Literal. See ResolvedPath::from_checked for why that single exemption is safe.
  • The body passed alongside has already had the path-consumed keys removed.

§What the value does NOT guarantee

It does not prove that a spec-declared narrowing (an OpenAPI pattern or maxLength) was applied — that depends on the implementor’s HttpExecutor::placeholder_rules override, and an implementor that keeps the default still gets the unconditional floor and the always-on cap but no narrowing. It is also a migration marker as much as a proof carrier: its job is to make a stale implementor written against the old &str parameter fail to COMPILE rather than silently receive already-resolved data and double-resolve it (Phase 128, D-09).

§Constructor shape

There is deliberately no new and no new_unchecked. A public unchecked constructor whose rustdoc claims an invariant is exactly the documented-but-absent class Phase 128 exists to correct, so the check lives inside the one constructor and the type cannot be forged from outside.

Implementations§

Source§

impl<'a> ResolvedPath<'a>

Source

pub fn from_checked(path: &'a str) -> Result<Self, PlaceholderRefusal>

Check path as a composed request path and wrap it on success.

This is the only constructor: it runs validate_resolved_target, so the invariant documented on the type is established here rather than asserted.

§The one narrowing: an author-written ? is permitted

validate_resolved_path refuses a query separator ANYWHERE, and core keeps that strict rule — it is a general-purpose composed-path checker and other callers want it. Its core SIBLING validate_resolved_target — which this constructor calls, and which the curated surface (pmcp_server_toolkit::http::HttpClient::check_composed_path) calls too, so the two cannot drift — splits at the FIRST ? and applies the full rule set to each side, which exempts exactly that one separator and nothing else.

Why that is safe rather than a hole. Both per-value floors already refuse ? in a substituted value, in literal AND percent-encoded form, with a decode-once pass so %253F-style regress cannot slip through. So a ? surviving into the composed string can only have come from a PathPart::Literal — script text the operator authored and shipped, not caller data. The asymmetry with traversal is the whole point: refusing .. from a literal catches a traversal bug, while refusing ? from a literal rejects legitimate authoring. Same rule, different work.

What the split does NOT relax, because a narrowing must not become a hole:

  • Traversal, control bytes, backslash, #, residual {/}, over-cap segments and empty interior segments are checked on both sides. So /a/../b?x=1 is still refused for the traversal, and /a?x=%00 is still refused for the control byte.
  • A SECOND ? is still refused: only the first is split off, so the query portion is checked by the unmodified rule, which denies ?.
  • An empty query portion is still refused — a dangling /x? is a doubled or trailing separator, which is the same class as a trailing /.
  • A ? reaching the composed string from a VALUE never gets here: the per-value floor has already refused it.

One inherited conservatism, stated so it is not a surprise: %25 is refused outright (it is what bounds the decode to a single pass), so a query carrying a percent-encoded percent sign is refused. That is unchanged from the path portion’s long-standing behaviour, not new here.

§Errors

Returns the PlaceholderRefusal from validate_resolved_target. The refusal is value-free: it names the rule and the declared expectation, never any byte of the path it refused.

Source

pub fn as_str(&self) -> &'a str

The resolved path as a string slice.

Trait Implementations§

Source§

impl<'a> Clone for ResolvedPath<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for ResolvedPath<'a>

Source§

impl<'a> Debug for ResolvedPath<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ResolvedPath<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for ResolvedPath<'a>

Source§

impl<'a> PartialEq for ResolvedPath<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for ResolvedPath<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ResolvedPath<'a>

§

impl<'a> RefUnwindSafe for ResolvedPath<'a>

§

impl<'a> Send for ResolvedPath<'a>

§

impl<'a> Sync for ResolvedPath<'a>

§

impl<'a> Unpin for ResolvedPath<'a>

§

impl<'a> UnsafeUnpin for ResolvedPath<'a>

§

impl<'a> UnwindSafe for ResolvedPath<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsOut<T> for T
where T: Copy,

Source§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Send for T
where T: ?Sized,

Source§

impl<T> Sync for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more