@@ -242,7 +242,7 @@ pub type RequestId = NumberOrString;
242242#[ serde( transparent) ]
243243#[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
244244pub struct ProgressToken ( pub NumberOrString ) ;
245- #[ derive( Debug , Clone ) ]
245+ #[ derive( Debug , Clone , Default ) ]
246246#[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
247247pub struct Request < M = String , P = JsonObject > {
248248 pub method : M ,
@@ -255,6 +255,16 @@ pub struct Request<M = String, P = JsonObject> {
255255 pub extensions : Extensions ,
256256}
257257
258+ impl < M : Default , P > Request < M , P > {
259+ pub fn new ( params : P ) -> Self {
260+ Self {
261+ method : Default :: default ( ) ,
262+ params,
263+ extensions : Extensions :: default ( ) ,
264+ }
265+ }
266+ }
267+
258268impl < M , P > GetExtensions for Request < M , P > {
259269 fn extensions ( & self ) -> & Extensions {
260270 & self . extensions
@@ -264,7 +274,7 @@ impl<M, P> GetExtensions for Request<M, P> {
264274 }
265275}
266276
267- #[ derive( Debug , Clone ) ]
277+ #[ derive( Debug , Clone , Default ) ]
268278#[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
269279pub struct RequestOptionalParam < M = String , P = JsonObject > {
270280 pub method : M ,
@@ -277,7 +287,17 @@ pub struct RequestOptionalParam<M = String, P = JsonObject> {
277287 pub extensions : Extensions ,
278288}
279289
280- #[ derive( Debug , Clone ) ]
290+ impl < M : Default , P > RequestOptionalParam < M , P > {
291+ pub fn with_param ( params : P ) -> Self {
292+ Self {
293+ method : Default :: default ( ) ,
294+ params : Some ( params) ,
295+ extensions : Extensions :: default ( ) ,
296+ }
297+ }
298+ }
299+
300+ #[ derive( Debug , Clone , Default ) ]
281301#[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
282302pub struct RequestNoParam < M = String > {
283303 pub method : M ,
@@ -296,7 +316,7 @@ impl<M> GetExtensions for RequestNoParam<M> {
296316 & mut self . extensions
297317 }
298318}
299- #[ derive( Debug , Clone ) ]
319+ #[ derive( Debug , Clone , Default ) ]
300320#[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
301321pub struct Notification < M = String , P = JsonObject > {
302322 pub method : M ,
@@ -308,7 +328,17 @@ pub struct Notification<M = String, P = JsonObject> {
308328 pub extensions : Extensions ,
309329}
310330
311- #[ derive( Debug , Clone ) ]
331+ impl < M : Default , P > Notification < M , P > {
332+ pub fn new ( params : P ) -> Self {
333+ Self {
334+ method : Default :: default ( ) ,
335+ params,
336+ extensions : Extensions :: default ( ) ,
337+ }
338+ }
339+ }
340+
341+ #[ derive( Debug , Clone , Default ) ]
312342#[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
313343pub struct NotificationNoParam < M = String > {
314344 pub method : M ,
0 commit comments