1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! Client configuration options.
//!
//! [`ClientOptions`] is the additive surface for configuring a [`crate::Client`]
//! beyond the protocol-level [`crate::shared::ProtocolOptions`]. This type is
//! marked `#[non_exhaustive]` so future configuration knobs can be added without
//! a breaking change.
/// 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):
///
/// ```rust,no_run
/// 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.