Skip to content

fix: use builder API for StreamableHttpClientTransportConfig (rmcp 1.3.0 compat)#986

Open
jefflower wants to merge 1 commit intoRightNow-AI:mainfrom
jefflower:fix/rmcp-non-exhaustive-compat
Open

fix: use builder API for StreamableHttpClientTransportConfig (rmcp 1.3.0 compat)#986
jefflower wants to merge 1 commit intoRightNow-AI:mainfrom
jefflower:fix/rmcp-non-exhaustive-compat

Conversation

@jefflower
Copy link
Copy Markdown

问题

rmcp 1.3.0 将 StreamableHttpClientTransportConfig 标记为 #[non_exhaustive],导致在定义 crate 外部无法使用结构体字面量构造(包括 ..Default::default() 填充语法),编译报错:

error[E0639]: cannot create non-exhaustive struct using struct expression

修复

将结构体字面量替换为官方提供的 builder API:

// 修复前(编译失败)
StreamableHttpClientTransportConfig {
    uri: url.to_string(),
    headers: HeaderMap::new(),
    ..Default::default()
}

// 修复后
StreamableHttpClientTransportConfig::with_uri(url)
    .custom_headers(headers)

同时移除了不再使用的 use std::sync::Arc 导入。

测试

  • cargo build --workspace --lib ✅ 编译通过
  • cargo test --workspace ✅ 所有测试通过(1744+)
  • cargo clippy --workspace --all-targets -- -D warnings ✅ 零 warning

🤖 Generated with Claude Code

`StreamableHttpClientTransportConfig` is marked `#[non_exhaustive]` in
rmcp 1.3.0, which forbids struct literal construction outside the
defining crate — even with `..Default::default()` fill syntax.

Replace the struct literal with the provided builder API:
  `StreamableHttpClientTransportConfig::with_uri(url).custom_headers(headers)`

Also drop the now-unused `use std::sync::Arc` import.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant