Skip to content

Commit 8700e5c

Browse files
authored
chore: fix all clippy warnings across workspace (#746)
1 parent 3bd7522 commit 8700e5c

File tree

8 files changed

+743
-793
lines changed

8 files changed

+743
-793
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ edition = "2024"
1212
version = "1.2.0"
1313
authors = ["4t145 <u4t145@163.com>"]
1414
license = "Apache-2.0"
15-
license-file = "LICENSE"
1615
repository = "https://github.com/modelcontextprotocol/rust-sdk/"
1716
description = "Rust SDK for Model Context Protocol"
1817
keywords = ["mcp", "sdk", "tokio", "modelcontextprotocol"]

conformance/src/bin/client.rs

Lines changed: 85 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::future::Future;
2-
31
use rmcp::{
42
ClientHandler, ErrorData, RoleClient, ServiceExt,
53
model::*,
@@ -55,82 +53,76 @@ impl ClientHandler for ElicitationDefaultsClientHandler {
5553
info
5654
}
5755

58-
fn create_elicitation(
56+
async fn create_elicitation(
5957
&self,
6058
request: CreateElicitationRequestParams,
6159
_cx: RequestContext<RoleClient>,
62-
) -> impl Future<Output = Result<CreateElicitationResult, ErrorData>> + Send + '_ {
63-
async move {
64-
let content = match &request {
65-
CreateElicitationRequestParams::FormElicitationParams {
66-
requested_schema, ..
67-
} => {
68-
let mut defaults = serde_json::Map::new();
69-
for (name, prop) in &requested_schema.properties {
70-
match prop {
71-
PrimitiveSchema::String(s) => {
72-
if let Some(d) = &s.default {
73-
defaults.insert(name.clone(), Value::String(d.clone()));
74-
}
60+
) -> Result<CreateElicitationResult, ErrorData> {
61+
let content = match &request {
62+
CreateElicitationRequestParams::FormElicitationParams {
63+
requested_schema, ..
64+
} => {
65+
let mut defaults = serde_json::Map::new();
66+
for (name, prop) in &requested_schema.properties {
67+
match prop {
68+
PrimitiveSchema::String(s) => {
69+
if let Some(d) = &s.default {
70+
defaults.insert(name.clone(), Value::String(d.clone()));
7571
}
76-
PrimitiveSchema::Number(n) => {
77-
if let Some(d) = n.default {
78-
defaults.insert(name.clone(), json!(d));
79-
}
72+
}
73+
PrimitiveSchema::Number(n) => {
74+
if let Some(d) = n.default {
75+
defaults.insert(name.clone(), json!(d));
8076
}
81-
PrimitiveSchema::Integer(i) => {
82-
if let Some(d) = i.default {
83-
defaults.insert(name.clone(), json!(d));
84-
}
77+
}
78+
PrimitiveSchema::Integer(i) => {
79+
if let Some(d) = i.default {
80+
defaults.insert(name.clone(), json!(d));
8581
}
86-
PrimitiveSchema::Boolean(b) => {
87-
if let Some(d) = b.default {
88-
defaults.insert(name.clone(), Value::Bool(d));
89-
}
82+
}
83+
PrimitiveSchema::Boolean(b) => {
84+
if let Some(d) = b.default {
85+
defaults.insert(name.clone(), Value::Bool(d));
9086
}
91-
PrimitiveSchema::Enum(e) => {
92-
let val = match e {
93-
EnumSchema::Single(SingleSelectEnumSchema::Untitled(u)) => {
94-
u.default.as_ref().map(|d| Value::String(d.clone()))
95-
}
96-
EnumSchema::Single(SingleSelectEnumSchema::Titled(t)) => {
97-
t.default.as_ref().map(|d| Value::String(d.clone()))
98-
}
99-
EnumSchema::Multi(MultiSelectEnumSchema::Untitled(u)) => {
100-
u.default.as_ref().map(|d| {
101-
Value::Array(
102-
d.iter()
103-
.map(|s| Value::String(s.clone()))
104-
.collect(),
105-
)
106-
})
107-
}
108-
EnumSchema::Multi(MultiSelectEnumSchema::Titled(t)) => {
109-
t.default.as_ref().map(|d| {
110-
Value::Array(
111-
d.iter()
112-
.map(|s| Value::String(s.clone()))
113-
.collect(),
114-
)
115-
})
116-
}
117-
EnumSchema::Legacy(_) => None,
118-
};
119-
if let Some(v) = val {
120-
defaults.insert(name.clone(), v);
87+
}
88+
PrimitiveSchema::Enum(e) => {
89+
let val = match e {
90+
EnumSchema::Single(SingleSelectEnumSchema::Untitled(u)) => {
91+
u.default.as_ref().map(|d| Value::String(d.clone()))
92+
}
93+
EnumSchema::Single(SingleSelectEnumSchema::Titled(t)) => {
94+
t.default.as_ref().map(|d| Value::String(d.clone()))
95+
}
96+
EnumSchema::Multi(MultiSelectEnumSchema::Untitled(u)) => {
97+
u.default.as_ref().map(|d| {
98+
Value::Array(
99+
d.iter().map(|s| Value::String(s.clone())).collect(),
100+
)
101+
})
102+
}
103+
EnumSchema::Multi(MultiSelectEnumSchema::Titled(t)) => {
104+
t.default.as_ref().map(|d| {
105+
Value::Array(
106+
d.iter().map(|s| Value::String(s.clone())).collect(),
107+
)
108+
})
121109
}
110+
EnumSchema::Legacy(_) => None,
111+
};
112+
if let Some(v) = val {
113+
defaults.insert(name.clone(), v);
122114
}
123115
}
124116
}
125-
Some(Value::Object(defaults))
126117
}
127-
_ => Some(json!({})),
128-
};
129-
Ok(CreateElicitationResult {
130-
action: ElicitationAction::Accept,
131-
content,
132-
})
133-
}
118+
Some(Value::Object(defaults))
119+
}
120+
_ => Some(json!({})),
121+
};
122+
Ok(CreateElicitationResult {
123+
action: ElicitationAction::Accept,
124+
content,
125+
})
134126
}
135127
}
136128

@@ -149,44 +141,40 @@ impl ClientHandler for FullClientHandler {
149141
info
150142
}
151143

152-
fn create_message(
144+
async fn create_message(
153145
&self,
154146
params: CreateMessageRequestParams,
155147
_cx: RequestContext<RoleClient>,
156-
) -> impl Future<Output = Result<CreateMessageResult, ErrorData>> + Send + '_ {
157-
async move {
158-
let prompt_text = params
159-
.messages
160-
.first()
161-
.and_then(|m| m.content.first())
162-
.and_then(|c| c.as_text())
163-
.map(|t| t.text.clone())
164-
.unwrap_or_default();
165-
Ok(CreateMessageResult::new(
166-
SamplingMessage::new(
167-
Role::Assistant,
168-
SamplingMessageContent::text(format!(
169-
"This is a mock LLM response to: {}",
170-
prompt_text
171-
)),
172-
),
173-
"mock-model".into(),
174-
)
175-
.with_stop_reason("endTurn"))
176-
}
148+
) -> Result<CreateMessageResult, ErrorData> {
149+
let prompt_text = params
150+
.messages
151+
.first()
152+
.and_then(|m| m.content.first())
153+
.and_then(|c| c.as_text())
154+
.map(|t| t.text.clone())
155+
.unwrap_or_default();
156+
Ok(CreateMessageResult::new(
157+
SamplingMessage::new(
158+
Role::Assistant,
159+
SamplingMessageContent::text(format!(
160+
"This is a mock LLM response to: {}",
161+
prompt_text
162+
)),
163+
),
164+
"mock-model".into(),
165+
)
166+
.with_stop_reason("endTurn"))
177167
}
178168

179-
fn create_elicitation(
169+
async fn create_elicitation(
180170
&self,
181171
_request: CreateElicitationRequestParams,
182172
_cx: RequestContext<RoleClient>,
183-
) -> impl Future<Output = Result<CreateElicitationResult, ErrorData>> + Send + '_ {
184-
async move {
185-
Ok(CreateElicitationResult {
186-
action: ElicitationAction::Accept,
187-
content: Some(json!({"username": "testuser", "email": "test@example.com"})),
188-
})
189-
}
173+
) -> Result<CreateElicitationResult, ErrorData> {
174+
Ok(CreateElicitationResult {
175+
action: ElicitationAction::Accept,
176+
content: Some(json!({"username": "testuser", "email": "test@example.com"})),
177+
})
190178
}
191179
}
192180

@@ -761,9 +749,7 @@ fn build_tool_arguments(tool: &Tool) -> Option<serde_json::Map<String, Value>> {
761749
})
762750
.unwrap_or_default();
763751

764-
let Some(properties) = properties else {
765-
return None;
766-
};
752+
let properties = properties?;
767753
if properties.is_empty() && required.is_empty() {
768754
return None;
769755
}

0 commit comments

Comments
 (0)