Skip to main content

PlaceholderRules

Struct PlaceholderRules 

Source
#[non_exhaustive]
pub struct PlaceholderRules<'a> { pub declared_pattern: Option<&'a str>, pub declared_max_length: Option<usize>, pub allow_slash: bool, }
Expand description

The D4 path-placeholder floor, re-exported from core pmcp.

There is exactly ONE implementation of these rules and it lives in pmcp::server::schema_validation. This is a pub use, never a second copy (Phase 128, Q2). Two reasons the home is core rather than here:

  1. The toolkit’s curated http build has no pmcp-code-mode edge and must not gain one (SC-1), so the shared rule cannot live in this crate.
  2. This repo has a documented three-way-drift incident from a security rule that existed in more than one copy, so a second denylist is a prohibited shape rather than a style preference.

The re-export exists because D-09 obliges the SDK to publish the helper under the name a third-party HttpExecutor implementor would look for. An implementor whose template syntax is not OpenAPI’s {key} can call pmcp_code_mode::validate_path_placeholder on each value it substitutes and pmcp_code_mode::validate_resolved_path on the composed result — or pmcp_code_mode::validate_resolved_target, which is that rule widened by the single author-written ? separator, and is what ResolvedPath::from_checked itself calls. Either reaches the same rule the SDK itself applies before calling HttpExecutor::execute_request. (Plain backticks, not an intra-doc link: executor is gated on js-runtime and the link would not resolve in a default-feature doc build.) The per-parameter narrowing a caller may declare on top of the floor.

Default means FLOOR-PLUS-CAP WITH NO NARROWING — all-None plus allow_slash: false. It emphatically does NOT mean “no checks”: the unconditional floor and PLACEHOLDER_MAX_LENGTH still apply, which is why PlaceholderRules::default() is a safe value for a trait’s default method body to return.

This struct is #[non_exhaustive], so another crate cannot build it with a struct literal. Use PlaceholderRules::default() and the with_* builders:

ⓘ
let rules = PlaceholderRules::default()
    .with_pattern(Some("^C[0-9]+$"))
    .with_max_length(Some(32));

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§declared_pattern: Option<&'a str>

A pattern declared for this parameter, which NARROWS the floor.

Never replaces it: a spec pattern of ^.*$ accepts every CR-01 payload (measured, RESEARCH Finding 5b), so pattern-supersedes-denylist would be a no-op (D-10).

§declared_max_length: Option<usize>

A maxLength declared for this parameter.

Narrows PLACEHOLDER_MAX_LENGTH further; a declared length LARGER than the constant never widens it.

§allow_slash: bool

Whether / is permitted inside this parameter’s value.

Its ONLY legitimate source is an explicit per-parameter entry in the server’s own config (D-11). An OpenAPI spec’s allowReserved must never be wired to it: a spec is third-party content baked into the package and that keyword is widely copy-pasted without intent. Even when this is true, the parent-directory sequence is refused with no escape.

Implementations§

Source§

impl<'a> PlaceholderRules<'a>

Source

pub fn with_pattern(self, pattern: Option<&'a str>) -> PlaceholderRules<'a>

Declare a narrowing pattern.

Source

pub fn with_max_length(self, max_length: Option<usize>) -> PlaceholderRules<'a>

Declare a narrowing maxLength.

Source

pub fn allowing_slash(self, allow_slash: bool) -> PlaceholderRules<'a>

Opt this parameter in to / (D-11 — config only, never spec-derived).

Trait Implementations§

Source§

impl<'a> Clone for PlaceholderRules<'a>

Source§

fn clone(&self) -> PlaceholderRules<'a>

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> Debug for PlaceholderRules<'a>

Source§

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

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

impl<'a> Default for PlaceholderRules<'a>

Source§

fn default() -> PlaceholderRules<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PlaceholderRules<'a>

§

impl<'a> RefUnwindSafe for PlaceholderRules<'a>

§

impl<'a> Send for PlaceholderRules<'a>

§

impl<'a> Sync for PlaceholderRules<'a>

§

impl<'a> Unpin for PlaceholderRules<'a>

§

impl<'a> UnsafeUnpin for PlaceholderRules<'a>

§

impl<'a> UnwindSafe for PlaceholderRules<'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> 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<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, 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