#[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:
- The toolkit’s curated
httpbuild has nopmcp-code-modeedge and must not gain one (SC-1), so the shared rule cannot live in this crate. - 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
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: boolWhether / 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>
impl<'a> PlaceholderRules<'a>
Sourcepub fn with_pattern(self, pattern: Option<&'a str>) -> PlaceholderRules<'a>
pub fn with_pattern(self, pattern: Option<&'a str>) -> PlaceholderRules<'a>
Declare a narrowing pattern.
Sourcepub fn with_max_length(self, max_length: Option<usize>) -> PlaceholderRules<'a>
pub fn with_max_length(self, max_length: Option<usize>) -> PlaceholderRules<'a>
Declare a narrowing maxLength.
Sourcepub fn allowing_slash(self, allow_slash: bool) -> PlaceholderRules<'a>
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>
impl<'a> Clone for PlaceholderRules<'a>
Source§fn clone(&self) -> PlaceholderRules<'a>
fn clone(&self) -> PlaceholderRules<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for PlaceholderRules<'a>
impl<'a> Debug for PlaceholderRules<'a>
Source§impl<'a> Default for PlaceholderRules<'a>
impl<'a> Default for PlaceholderRules<'a>
Source§fn default() -> PlaceholderRules<'a>
fn default() -> PlaceholderRules<'a>
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> 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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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