Skip to main content

Parameter

Struct Parameter 

Source
pub struct Parameter {
    pub name: String,
    pub location: ParameterLocation,
    pub required: bool,
    pub pattern: Option<String>,
    pub max_length: Option<u64>,
    pub allow_slash: bool,
}
Expand description

A single OpenAPI operation parameter.

§The three rule fields (Phase 128, D4(b))

Self::pattern, Self::max_length and Self::allow_slash carry the DECLARED narrowing for this parameter to the substitution point in crate::http::HttpClient, where pmcp::server::schema_validation::validate_path_placeholder reads them through Parameter::placeholder_rules. They are deliberately NOT feature-gated — they are plain scalars, they are #[serde(default)], and gating them would make this struct’s serialized shape feature-dependent, which is a worse break than gating the accessor that names a feature-gated type.

Fields§

§name: String

Parameter name (matches the {name} placeholder for path params).

§location: ParameterLocation

Where the parameter is carried in the request.

§required: bool

Whether the parameter is required.

§pattern: Option<String>

Declared regular expression the value must match (Phase 128, D4(b)).

NARROWS the unconditional character floor; it never replaces it (D-10). Populated from [[tools.parameters]] pattern for a curated tool and from a spec parameter’s own string schema for a spec-driven one.

§max_length: Option<u64>

Declared maximum length in Unicode code points (Phase 128, D4(b)).

NARROWS the always-on pmcp::server::schema_validation::PLACEHOLDER_MAX_LENGTH cap; a declared value above that constant cannot widen it (D-08).

§allow_slash: bool

Permit / inside this parameter’s substituted value (Phase 128, D-11).

The ONLY legitimate source is the server’s own [[tools.parameters]] allow_slash. A parsed OpenAPI document must never set it — see Parameter::placeholder_rules and crate::config::ParamDecl::allow_slash for why.

Implementations§

Source§

impl Parameter

Source

pub fn new( name: impl Into<String>, location: ParameterLocation, required: bool, ) -> Self

Construct a parameter (test/parser convenience).

The Phase 128 rule fields default to “no declared narrowing”, so every pre-Phase-128 call site keeps compiling unchanged and gets the unconditional floor plus the always-on cap. Attach declared rules with Self::with_rules.

Source

pub fn with_rules( self, pattern: Option<String>, max_length: Option<u64>, allow_slash: bool, ) -> Self

Attach the declared placeholder rules (Phase 128, D4(b)).

A consuming builder rather than three setters, so the three values that travel together are set together.

Source

pub fn placeholder_rules(&self) -> PlaceholderRules<'_>

This parameter’s declared rules as a pmcp::server::schema_validation::PlaceholderRules (Phase 128, D4(b)).

§D-10 — the returned rules NARROW, they never replace

validate_path_placeholder applies its unconditional character floor and its always-on length cap FIRST and consults these rules afterwards, so a permissive declared pattern such as ^.*$ cannot switch the injection check off. A declared max_length above PLACEHOLDER_MAX_LENGTH likewise cannot widen the constant.

§D-11 — allow_slash is config-only

The returned allow_slash comes from the server’s own [[tools.parameters]] declaration and from nowhere else. An OpenAPI document’s reserved-expansion keyword must NEVER be wired to it: a spec is third-party content baked into a package, that keyword describes percent-encoding latitude in the spec author’s serialization rules rather than permission to restructure the request target, and it is widely copy-pasted without intent. The parser in this module therefore leaves allow_slash false unconditionally.

§The curated template parser recognizes WHOLE-SEGMENT placeholders only

On the curated single-call surface a placeholder is a whole /-delimited segment: crate::config::path_placeholder_names matches {name} spanning an entire segment and nothing else. So /search/{a}{b} is NOT two placeholders (it parses as the single name a}{b) and /prefix-{id} is not recognized as carrying a placeholder at all. Attaching rules to a Parameter does not change that parse. Both shapes are refused at CONFIG time by crate::config::ServerConfig::validate, so neither can reach runtime from a [[tools]] declaration — but a spec-derived operation is not config-validated, which is why the composed-path check at the tail of substitution is what closes a residual {/} there.

Trait Implementations§

Source§

impl Clone for Parameter

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 Debug for Parameter

Source§

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

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

impl<'de> Deserialize<'de> for Parameter

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Parameter

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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