Skip to content

Commit 22f5fa8

Browse files
committed
fix(model): keep public signatures on the deprecated aliases
The public API check compares rendered signatures, and rustdoc records a type alias by the name it was written with. Respelling `ServerHandler::get_info`, `ClientHandler::get_info`, `DiscoverResult::from_server_info` and `impl ClientHandler for ClientInfo` onto `InitializeResult`/`InitializeRequestParams` therefore reads as changed public items even though the aliases resolve to those exact types and nothing downstream breaks. Put those four signatures back on the aliases so the published API is byte-identical, and note why at the alias definitions. The deprecation still steers new code, and the macro output, tests, examples and docs keep using the canonical names.
1 parent 9e9b8de commit 22f5fa8

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

crates/rmcp/src/handler/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ macro_rules! client_handler_methods {
274274
std::future::ready(())
275275
}
276276

277-
fn get_info(&self) -> InitializeRequestParams {
277+
fn get_info(&self) -> ClientInfo {
278278
InitializeRequestParams::default()
279279
}
280280
};
@@ -296,8 +296,8 @@ pub trait ClientHandler: Sized + 'static {
296296
impl ClientHandler for () {}
297297

298298
/// Do nothing, with a specific client info.
299-
impl ClientHandler for InitializeRequestParams {
300-
fn get_info(&self) -> InitializeRequestParams {
299+
impl ClientHandler for ClientInfo {
300+
fn get_info(&self) -> ClientInfo {
301301
self.clone()
302302
}
303303
}
@@ -422,7 +422,7 @@ macro_rules! impl_client_handler_for_wrapper {
422422
(**self).on_custom_notification(notification, context)
423423
}
424424

425-
fn get_info(&self) -> InitializeRequestParams {
425+
fn get_info(&self) -> ClientInfo {
426426
(**self).get_info()
427427
}
428428
}

crates/rmcp/src/handler/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ macro_rules! server_handler_methods {
550550
std::future::ready(())
551551
}
552552

553-
fn get_info(&self) -> InitializeResult {
553+
fn get_info(&self) -> ServerInfo {
554554
InitializeResult::default()
555555
}
556556

@@ -782,7 +782,7 @@ macro_rules! impl_server_handler_for_wrapper {
782782
(**self).on_custom_notification(notification, context)
783783
}
784784

785-
fn get_info(&self) -> InitializeResult {
785+
fn get_info(&self) -> ServerInfo {
786786
(**self).get_info()
787787
}
788788

crates/rmcp/src/model.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,14 @@ impl InitializeResult {
10861086
///
10871087
/// Prefer [`InitializeResult`]. The name collides with the protocol's
10881088
/// `serverInfo` field, which is only the [`Implementation`] identity (#1082).
1089+
//
1090+
// The signatures this crate publishes (`ServerHandler::get_info`,
1091+
// `DiscoverResult::from_server_info`, and the `ClientInfo` equivalents below)
1092+
// keep spelling the alias. It resolves to the same type, so the spelling makes
1093+
// no difference to callers, but rustdoc records the name as written and the
1094+
// public API check treats a respelling as a changed item. Moving those
1095+
// signatures onto the canonical names is a documented API change and belongs in
1096+
// the next major release.
10891097
#[deprecated(note = "use `InitializeResult` instead")]
10901098
pub type ServerInfo = InitializeResult;
10911099

@@ -1256,7 +1264,7 @@ impl DiscoverResult {
12561264
/// Create a discovery result from the server's initialization information.
12571265
pub fn from_server_info(
12581266
supported_versions: Vec<ProtocolVersion>,
1259-
server_info: InitializeResult,
1267+
server_info: ServerInfo,
12601268
) -> Self {
12611269
let InitializeResult {
12621270
capabilities,

0 commit comments

Comments
 (0)