Skip to content

Commit 9a0abb9

Browse files
authored
feat: more type conversion utilities (#36)
1 parent 08854f0 commit 9a0abb9

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed

src/generated_schema/2024_11_05/mcp_schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
///
77
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
88
/// Hash : bb1446ff1810a0df57989d78366d626d2c01b9d7
9-
/// Generated at : 2025-02-22 11:48:41
9+
/// Generated at : 2025-02-22 12:06:03
1010
/// ----------------------------------------------------------------------------
1111
///
1212
/// MCP Protocol Version

src/generated_schema/2024_11_05/schema_utils.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,30 @@ pub enum MessageFromServer {
11871187
Error(JsonrpcErrorError),
11881188
}
11891189

1190+
impl From<RequestFromServer> for MessageFromServer {
1191+
fn from(value: RequestFromServer) -> Self {
1192+
Self::RequestFromServer(value)
1193+
}
1194+
}
1195+
1196+
impl From<ResultFromServer> for MessageFromServer {
1197+
fn from(value: ResultFromServer) -> Self {
1198+
Self::ResultFromServer(value)
1199+
}
1200+
}
1201+
1202+
impl From<NotificationFromServer> for MessageFromServer {
1203+
fn from(value: NotificationFromServer) -> Self {
1204+
Self::NotificationFromServer(value)
1205+
}
1206+
}
1207+
1208+
impl From<JsonrpcErrorError> for MessageFromServer {
1209+
fn from(value: JsonrpcErrorError) -> Self {
1210+
Self::Error(value)
1211+
}
1212+
}
1213+
11901214
impl MCPMessage for MessageFromServer {
11911215
fn is_response(&self) -> bool {
11921216
matches!(self, MessageFromServer::ResultFromServer(_))
@@ -1271,6 +1295,30 @@ pub enum MessageFromClient {
12711295
Error(JsonrpcErrorError),
12721296
}
12731297

1298+
impl From<RequestFromClient> for MessageFromClient {
1299+
fn from(value: RequestFromClient) -> Self {
1300+
Self::RequestFromClient(value)
1301+
}
1302+
}
1303+
1304+
impl From<ResultFromClient> for MessageFromClient {
1305+
fn from(value: ResultFromClient) -> Self {
1306+
Self::ResultFromClient(value)
1307+
}
1308+
}
1309+
1310+
impl From<NotificationFromClient> for MessageFromClient {
1311+
fn from(value: NotificationFromClient) -> Self {
1312+
Self::NotificationFromClient(value)
1313+
}
1314+
}
1315+
1316+
impl From<JsonrpcErrorError> for MessageFromClient {
1317+
fn from(value: JsonrpcErrorError) -> Self {
1318+
Self::Error(value)
1319+
}
1320+
}
1321+
12741322
impl FromMessage<MessageFromClient> for ClientMessage {
12751323
fn from_message(
12761324
message: MessageFromClient,

src/generated_schema/draft/mcp_schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
///
77
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
88
/// Hash : bb1446ff1810a0df57989d78366d626d2c01b9d7
9-
/// Generated at : 2025-02-22 11:48:41
9+
/// Generated at : 2025-02-22 12:06:03
1010
/// ----------------------------------------------------------------------------
1111
///
1212
/// MCP Protocol Version

src/generated_schema/draft/schema_utils.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,30 @@ pub enum MessageFromServer {
11871187
Error(JsonrpcErrorError),
11881188
}
11891189

1190+
impl From<RequestFromServer> for MessageFromServer {
1191+
fn from(value: RequestFromServer) -> Self {
1192+
Self::RequestFromServer(value)
1193+
}
1194+
}
1195+
1196+
impl From<ResultFromServer> for MessageFromServer {
1197+
fn from(value: ResultFromServer) -> Self {
1198+
Self::ResultFromServer(value)
1199+
}
1200+
}
1201+
1202+
impl From<NotificationFromServer> for MessageFromServer {
1203+
fn from(value: NotificationFromServer) -> Self {
1204+
Self::NotificationFromServer(value)
1205+
}
1206+
}
1207+
1208+
impl From<JsonrpcErrorError> for MessageFromServer {
1209+
fn from(value: JsonrpcErrorError) -> Self {
1210+
Self::Error(value)
1211+
}
1212+
}
1213+
11901214
impl MCPMessage for MessageFromServer {
11911215
fn is_response(&self) -> bool {
11921216
matches!(self, MessageFromServer::ResultFromServer(_))
@@ -1271,6 +1295,30 @@ pub enum MessageFromClient {
12711295
Error(JsonrpcErrorError),
12721296
}
12731297

1298+
impl From<RequestFromClient> for MessageFromClient {
1299+
fn from(value: RequestFromClient) -> Self {
1300+
Self::RequestFromClient(value)
1301+
}
1302+
}
1303+
1304+
impl From<ResultFromClient> for MessageFromClient {
1305+
fn from(value: ResultFromClient) -> Self {
1306+
Self::ResultFromClient(value)
1307+
}
1308+
}
1309+
1310+
impl From<NotificationFromClient> for MessageFromClient {
1311+
fn from(value: NotificationFromClient) -> Self {
1312+
Self::NotificationFromClient(value)
1313+
}
1314+
}
1315+
1316+
impl From<JsonrpcErrorError> for MessageFromClient {
1317+
fn from(value: JsonrpcErrorError) -> Self {
1318+
Self::Error(value)
1319+
}
1320+
}
1321+
12741322
impl FromMessage<MessageFromClient> for ClientMessage {
12751323
fn from_message(
12761324
message: MessageFromClient,

0 commit comments

Comments
 (0)