#[non_exhaustive]pub struct Request<M = String, P = Map<String, Value>> {
pub method: M,
pub params: P,
pub extensions: Extensions,
}Available on crate features
mcp and tools only.Expand description
Represents a JSON-RPC request with method, parameters, and extensions.
This is the core structure for all MCP requests, containing:
method: The name of the method being calledparams: The parameters for the methodextensions: Additional context data (similar to HTTP headers)
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.method: M§params: P§extensions: Extensionsextensions will carry anything possible in the context, including the metadata
(RequestMetaObject for requests, NotificationMetaObject for notifications)
this is similar with the Extensions in http crate
Implementations§
Trait Implementations§
Source§impl<'de, M, R> Deserialize<'de> for Request<M, R>where
M: Deserialize<'de>,
R: Deserialize<'de>,
impl<'de, M, R> Deserialize<'de> for Request<M, R>where
M: Deserialize<'de>,
R: Deserialize<'de>,
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Request<M, R>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Request<M, R>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Request<CallToolRequestMethod, CallToolRequestParams>> for ClientRequest
impl From<Request<CallToolRequestMethod, CallToolRequestParams>> for ClientRequest
Source§fn from(
value: Request<CallToolRequestMethod, CallToolRequestParams>,
) -> ClientRequest
fn from( value: Request<CallToolRequestMethod, CallToolRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<CancelTaskMethod, CancelTaskParams>> for ClientRequest
impl From<Request<CancelTaskMethod, CancelTaskParams>> for ClientRequest
Source§fn from(value: Request<CancelTaskMethod, CancelTaskParams>) -> ClientRequest
fn from(value: Request<CancelTaskMethod, CancelTaskParams>) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<CompleteRequestMethod, CompleteRequestParams>> for ClientRequest
impl From<Request<CompleteRequestMethod, CompleteRequestParams>> for ClientRequest
Source§fn from(
value: Request<CompleteRequestMethod, CompleteRequestParams>,
) -> ClientRequest
fn from( value: Request<CompleteRequestMethod, CompleteRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<CreateMessageRequestMethod, CreateMessageRequestParams>> for ServerRequest
impl From<Request<CreateMessageRequestMethod, CreateMessageRequestParams>> for ServerRequest
Source§fn from(
value: Request<CreateMessageRequestMethod, CreateMessageRequestParams>,
) -> ServerRequest
fn from( value: Request<CreateMessageRequestMethod, CreateMessageRequestParams>, ) -> ServerRequest
Converts to this type from the input type.
Source§impl From<Request<DiscoverRequestMethod, DiscoverRequestParams>> for ClientRequest
impl From<Request<DiscoverRequestMethod, DiscoverRequestParams>> for ClientRequest
Source§fn from(
value: Request<DiscoverRequestMethod, DiscoverRequestParams>,
) -> ClientRequest
fn from( value: Request<DiscoverRequestMethod, DiscoverRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<ElicitationCreateRequestMethod, ElicitRequestParams>> for ServerRequest
impl From<Request<ElicitationCreateRequestMethod, ElicitRequestParams>> for ServerRequest
Source§fn from(
value: Request<ElicitationCreateRequestMethod, ElicitRequestParams>,
) -> ServerRequest
fn from( value: Request<ElicitationCreateRequestMethod, ElicitRequestParams>, ) -> ServerRequest
Converts to this type from the input type.
Source§impl From<Request<GetPromptRequestMethod, GetPromptRequestParams>> for ClientRequest
impl From<Request<GetPromptRequestMethod, GetPromptRequestParams>> for ClientRequest
Source§fn from(
value: Request<GetPromptRequestMethod, GetPromptRequestParams>,
) -> ClientRequest
fn from( value: Request<GetPromptRequestMethod, GetPromptRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<GetTaskMethod, GetTaskParams>> for ClientRequest
impl From<Request<GetTaskMethod, GetTaskParams>> for ClientRequest
Source§fn from(value: Request<GetTaskMethod, GetTaskParams>) -> ClientRequest
fn from(value: Request<GetTaskMethod, GetTaskParams>) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<InitializeResultMethod, InitializeRequestParams>> for ClientRequest
impl From<Request<InitializeResultMethod, InitializeRequestParams>> for ClientRequest
Source§fn from(
value: Request<InitializeResultMethod, InitializeRequestParams>,
) -> ClientRequest
fn from( value: Request<InitializeResultMethod, InitializeRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<ReadResourceRequestMethod, ReadResourceRequestParams>> for ClientRequest
impl From<Request<ReadResourceRequestMethod, ReadResourceRequestParams>> for ClientRequest
Source§fn from(
value: Request<ReadResourceRequestMethod, ReadResourceRequestParams>,
) -> ClientRequest
fn from( value: Request<ReadResourceRequestMethod, ReadResourceRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<SetLevelRequestMethod, SetLevelRequestParams>> for ClientRequest
impl From<Request<SetLevelRequestMethod, SetLevelRequestParams>> for ClientRequest
Source§fn from(
value: Request<SetLevelRequestMethod, SetLevelRequestParams>,
) -> ClientRequest
fn from( value: Request<SetLevelRequestMethod, SetLevelRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<SubscribeRequestMethod, SubscribeRequestParams>> for ClientRequest
impl From<Request<SubscribeRequestMethod, SubscribeRequestParams>> for ClientRequest
Source§fn from(
value: Request<SubscribeRequestMethod, SubscribeRequestParams>,
) -> ClientRequest
fn from( value: Request<SubscribeRequestMethod, SubscribeRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<SubscriptionsListenRequestMethod, SubscriptionsListenRequestParams>> for ClientRequest
impl From<Request<SubscriptionsListenRequestMethod, SubscriptionsListenRequestParams>> for ClientRequest
Source§fn from(
value: Request<SubscriptionsListenRequestMethod, SubscriptionsListenRequestParams>,
) -> ClientRequest
fn from( value: Request<SubscriptionsListenRequestMethod, SubscriptionsListenRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<UnsubscribeRequestMethod, UnsubscribeRequestParams>> for ClientRequest
impl From<Request<UnsubscribeRequestMethod, UnsubscribeRequestParams>> for ClientRequest
Source§fn from(
value: Request<UnsubscribeRequestMethod, UnsubscribeRequestParams>,
) -> ClientRequest
fn from( value: Request<UnsubscribeRequestMethod, UnsubscribeRequestParams>, ) -> ClientRequest
Converts to this type from the input type.
Source§impl From<Request<UpdateTaskMethod, UpdateTaskParams>> for ClientRequest
impl From<Request<UpdateTaskMethod, UpdateTaskParams>> for ClientRequest
Source§fn from(value: Request<UpdateTaskMethod, UpdateTaskParams>) -> ClientRequest
fn from(value: Request<UpdateTaskMethod, UpdateTaskParams>) -> ClientRequest
Converts to this type from the input type.
Source§impl<M, P> GetExtensions for Request<M, P>
impl<M, P> GetExtensions for Request<M, P>
fn extensions(&self) -> &Extensions
fn extensions_mut(&mut self) -> &mut Extensions
Source§impl<M, P> JsonSchema for Request<M, P>where
M: JsonSchema,
P: JsonSchema,
impl<M, P> JsonSchema for Request<M, P>where
M: JsonSchema,
P: JsonSchema,
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreAuto Trait Implementations§
impl<M = String, P = Map<String, Value>> !RefUnwindSafe for Request<M, P>
impl<M = String, P = Map<String, Value>> !UnwindSafe for Request<M, P>
impl<M, P> Freeze for Request<M, P>
impl<M, P> Send for Request<M, P>
impl<M, P> Sync for Request<M, P>
impl<M, P> Unpin for Request<M, P>
impl<M, P> UnsafeUnpin for Request<M, P>where
M: UnsafeUnpin,
P: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.