chore: add #[non_exhaustive] and mutation methods to improve compatibility (#715)

* chore: add #[non_exhaustive] to reduce backwards-incompatible changes going forward

* fix: remove ProtocolVersion import

* fix: add a few more with_ mutator methods

---------

Co-authored-by: Alex Hancock <alexhancock@block.xyz>
This commit is contained in:
Jack Amadeo 2026-03-03 10:38:01 -05:00 • committed by GitHub
commit f63718d202
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1568 additions and 1110 deletions

View file

@ -25,6 +25,7 @@ use crate::{
///
/// if you want to handle the error, you can use `serve_client_with_ct` or `serve_client` with `Result<RunningService<RoleClient, S>, ClientError>`
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum ClientInitializeError {
#[error("expect initialized response, but received: {0:?}")]
ExpectedInitResponse(Option<ServerJsonRpcMessage>),

View file

@ -47,6 +47,7 @@ impl ServiceRole for RoleServer {
///
/// if you want to handle the error, you can use `serve_server_with_ct` or `serve_server` with `Result<RunningService<RoleServer, S>, ServerError>`
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum ServerInitializeError {
#[error("expect initialized request, but received: {0:?}")]
ExpectedInitializeRequest(Option<ClientJsonRpcMessage>),
@ -457,6 +458,7 @@ impl Peer<RoleServer> {
/// Errors that can occur during typed elicitation operations
#[cfg(feature = "elicitation")]
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum ElicitationError {
/// The elicitation request failed at the service level
#[error("Service error: {0}")]
@ -808,6 +810,7 @@ impl Peer<RoleServer> {
/// ElicitationAction::Cancel => {
/// println!("User cancelled/dismissed the request");
/// }
/// _ => {}
/// }
/// Ok(())
/// }
@ -858,6 +861,7 @@ impl Peer<RoleServer> {
/// ElicitationAction::Cancel => {
/// println!("User cancelled/dismissed the request");
/// }
/// _ => {}
/// }
/// Ok(())
/// }