#[non_exhaustive]pub struct ClientOptions {
pub max_iterations: usize,
}Expand description
Client-level configuration.
Constructed via ClientOptions::default combined with field-update
syntax. From outside the pmcp crate the struct literal is forbidden by
#[non_exhaustive], so callers must always spread ..Default::default().
§Memory amplification note
Settings like max_iterations bound how many pages the list_all_*
helpers will accumulate in memory before returning. Because those helpers
return a fully materialised Vec, they are memory-amplifying convenience
APIs. For very large servers, prefer the paginated single-page
crate::Client::list_tools / list_prompts / list_resources /
list_resource_templates methods and stream the output.
§max_iterations = 0
Setting max_iterations = 0 is legal but degenerate: the list_all_*
bounded loop performs zero iterations and immediately returns
crate::Error::Validation with the cap-exceeded message. Callers should
treat this as “disabled” — use a small positive integer if you want at
least one page fetched.
§Examples
From downstream crates (external — #[non_exhaustive] forbids the struct
literal, so use ClientOptions::default + a setter or direct assignment):
use pmcp::ClientOptions;
let opts = ClientOptions::default().with_max_iterations(50);
assert_eq!(opts.max_iterations, 50);
// Equivalent mutable form:
let mut opts = ClientOptions::default();
opts.max_iterations = 50;
assert_eq!(opts.max_iterations, 50);From inside the pmcp crate (or any crate-internal consumer) the
field-update idiom also compiles — ClientOptions { max_iterations: 50, ..Default::default() } — but external crates must use the two forms
above.
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.max_iterations: usizeMaximum number of pagination iterations list_all_* helpers will
perform before returning crate::Error::Validation. Default: 100.
0 is legal but produces an immediate cap-exceeded error — see the
struct-level docs.
Implementations§
Source§impl ClientOptions
impl ClientOptions
Sourcepub fn with_max_iterations(self, max_iterations: usize) -> Self
pub fn with_max_iterations(self, max_iterations: usize) -> Self
Builder-style setter for Self::max_iterations.
Provided so downstream crates can configure a non-default
max_iterations without running into the #[non_exhaustive]
struct-literal restriction.
§Examples
use pmcp::ClientOptions;
let opts = ClientOptions::default().with_max_iterations(25);
assert_eq!(opts.max_iterations, 25);Trait Implementations§
Source§impl Clone for ClientOptions
impl Clone for ClientOptions
Source§fn clone(&self) -> ClientOptions
fn clone(&self) -> ClientOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more