feat(model): expose client method name (#391)
This is useful for including in logs etc. Without this its pretty painful to extract manually
This commit is contained in:
parent
98b77fd94a
commit
7a67482777
1 changed files with 23 additions and 0 deletions
|
|
@ -58,6 +58,9 @@ pub struct EmptyObject {}
|
||||||
|
|
||||||
pub trait ConstString: Default {
|
pub trait ConstString: Default {
|
||||||
const VALUE: &str;
|
const VALUE: &str;
|
||||||
|
fn as_str(&self) -> &'static str {
|
||||||
|
Self::VALUE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! const_string {
|
macro_rules! const_string {
|
||||||
|
|
@ -1491,6 +1494,26 @@ ts_union!(
|
||||||
| ListToolsRequest;
|
| ListToolsRequest;
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl ClientRequest {
|
||||||
|
pub fn method(&self) -> &'static str {
|
||||||
|
match &self {
|
||||||
|
ClientRequest::PingRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::InitializeRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::CompleteRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::SetLevelRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::GetPromptRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::ListPromptsRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::ListResourcesRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::ListResourceTemplatesRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::ReadResourceRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::SubscribeRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::UnsubscribeRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::CallToolRequest(r) => r.method.as_str(),
|
||||||
|
ClientRequest::ListToolsRequest(r) => r.method.as_str(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ts_union!(
|
ts_union!(
|
||||||
export type ClientNotification =
|
export type ClientNotification =
|
||||||
| CancelledNotification
|
| CancelledNotification
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue