1use std::any::TypeId;
2use std::collections::VecDeque;
3use std::fmt::Debug;
4
5use clap::builder::{IntoResettable, StyledStr};
6use clap::{CommandFactory, FromArgMatches};
7use imbl_value::imbl::OrdMap;
8use imbl_value::Value;
9use serde::de::DeserializeOwned;
10use serde::Serialize;
11use yajrc::RpcError;
12
13use crate::util::{Flat, PhantomData};
14use crate::{
15 CallRemote, CallRemoteHandler, CliBindings, DynHandler, Handler, HandlerArgs, HandlerArgsFor,
16 HandlerFor, HandlerTypes, OrEmpty, PrintCliResult, WithContext,
17};
18
19pub trait HandlerExt<Context: crate::Context>: HandlerFor<Context> + Sized {
20 fn no_cli(self) -> NoCli<Self>;
21 fn no_display(self) -> NoDisplay<Self>;
22 fn with_custom_display<C: crate::Context, P>(self, display: P) -> CustomDisplay<P, Self>
23 where
24 P: PrintCliResult<
25 C,
26 Params = Self::Params,
27 InheritedParams = Self::InheritedParams,
28 Ok = Self::Ok,
29 Err = Self::Err,
30 >;
31 fn with_custom_display_fn<C: crate::Context, F>(
32 self,
33 display: F,
34 ) -> CustomDisplayFn<F, Self, C>
35 where
36 F: Fn(HandlerArgsFor<C, Self>, Self::Ok) -> Result<(), Self::Err>;
37 fn with_inherited<Params, InheritedParams, F>(
38 self,
39 f: F,
40 ) -> InheritanceHandler<Params, InheritedParams, Self, F>
41 where
42 F: Fn(Params, InheritedParams) -> Self::InheritedParams;
43 fn with_call_remote<C>(self) -> RemoteCaller<C, Context, Self>;
44 fn with_about<M>(self, message: M) -> WithAbout<M, Self>
45 where
46 M: IntoResettable<StyledStr>;
47}
48
49impl<Context: crate::Context, T: HandlerFor<Context> + Sized> HandlerExt<Context> for T {
50 fn no_cli(self) -> NoCli<Self> {
51 NoCli(self)
52 }
53 fn no_display(self) -> NoDisplay<Self> {
54 NoDisplay(self)
55 }
56 fn with_custom_display<C: crate::Context, P>(self, display: P) -> CustomDisplay<P, Self>
57 where
58 P: PrintCliResult<
59 C,
60 Params = Self::Params,
61 InheritedParams = Self::InheritedParams,
62 Ok = Self::Ok,
63 Err = Self::Err,
64 >,
65 {
66 CustomDisplay {
67 print: display,
68 handler: self,
69 }
70 }
71 fn with_custom_display_fn<C: crate::Context, F>(self, display: F) -> CustomDisplayFn<F, Self, C>
72 where
73 F: Fn(HandlerArgsFor<C, Self>, Self::Ok) -> Result<(), Self::Err>,
74 {
75 CustomDisplayFn {
76 _phantom: PhantomData::new(),
77 print: display,
78 handler: self,
79 }
80 }
81 fn with_inherited<Params, InheritedParams, F>(
82 self,
83 f: F,
84 ) -> InheritanceHandler<Params, InheritedParams, Self, F>
85 where
86 F: Fn(Params, InheritedParams) -> Self::InheritedParams,
87 {
88 InheritanceHandler {
89 _phantom: PhantomData::new(),
90 handler: self,
91 inherit: f,
92 }
93 }
94 fn with_call_remote<C>(self) -> RemoteCaller<C, Context, Self> {
95 RemoteCaller {
96 _phantom: PhantomData::new(),
97 handler: self,
98 }
99 }
100
101 fn with_about<M>(self, message: M) -> WithAbout<M, Self>
102 where
103 M: IntoResettable<StyledStr>,
104 {
105 WithAbout {
106 handler: self,
107 message,
108 }
109 }
110}
111
112#[derive(Debug, Clone)]
113pub struct NoCli<H>(pub H);
114impl<H: HandlerTypes> HandlerTypes for NoCli<H> {
115 type Params = H::Params;
116 type InheritedParams = H::InheritedParams;
117 type Ok = H::Ok;
118 type Err = H::Err;
119}
120impl<Context, H> HandlerFor<Context> for NoCli<H>
121where
122 Context: crate::Context,
123 H: HandlerFor<Context>,
124{
125 fn handle_sync(
126 &self,
127 HandlerArgs {
128 context,
129 parent_method,
130 method,
131 params,
132 inherited_params,
133 raw_params,
134 }: HandlerArgsFor<Context, Self>,
135 ) -> Result<Self::Ok, Self::Err> {
136 self.0.handle_sync(HandlerArgs {
137 context,
138 parent_method,
139 method,
140 params,
141 inherited_params,
142 raw_params,
143 })
144 }
145 async fn handle_async(
146 &self,
147 HandlerArgs {
148 context,
149 parent_method,
150 method,
151 params,
152 inherited_params,
153 raw_params,
154 }: HandlerArgsFor<Context, Self>,
155 ) -> Result<Self::Ok, Self::Err> {
156 self.0
157 .handle_async(HandlerArgs {
158 context,
159 parent_method,
160 method,
161 params,
162 inherited_params,
163 raw_params,
164 })
165 .await
166 }
167 fn metadata(&self, method: VecDeque<&'static str>) -> OrdMap<&'static str, Value> {
168 self.0.metadata(method)
169 }
170 fn method_from_dots(&self, method: &str) -> Option<VecDeque<&'static str>> {
171 self.0.method_from_dots(method)
172 }
173}
174impl<Context, H> CliBindings<Context> for NoCli<H>
175where
176 Context: crate::Context,
177 H: HandlerTypes,
178{
179 const NO_CLI: bool = true;
180 fn cli_command(&self) -> clap::Command {
181 unimplemented!()
182 }
183 fn cli_parse(
184 &self,
185 _: &clap::ArgMatches,
186 ) -> Result<(VecDeque<&'static str>, Value), clap::Error> {
187 unimplemented!()
188 }
189 fn cli_display(&self, _: HandlerArgsFor<Context, Self>, _: Self::Ok) -> Result<(), Self::Err> {
190 unimplemented!()
191 }
192}
193
194#[derive(Debug, Clone)]
195pub struct NoDisplay<H>(pub H);
196impl<H: HandlerTypes> HandlerTypes for NoDisplay<H> {
197 type Params = H::Params;
198 type InheritedParams = H::InheritedParams;
199 type Ok = H::Ok;
200 type Err = H::Err;
201}
202
203impl<Context, H> HandlerFor<Context> for NoDisplay<H>
204where
205 Context: crate::Context,
206 H: HandlerFor<Context>,
207{
208 fn handle_sync(
209 &self,
210 HandlerArgs {
211 context,
212 parent_method,
213 method,
214 params,
215 inherited_params,
216 raw_params,
217 }: HandlerArgsFor<Context, Self>,
218 ) -> Result<Self::Ok, Self::Err> {
219 self.0.handle_sync(HandlerArgs {
220 context,
221 parent_method,
222 method,
223 params,
224 inherited_params,
225 raw_params,
226 })
227 }
228 async fn handle_async(
229 &self,
230 HandlerArgs {
231 context,
232 parent_method,
233 method,
234 params,
235 inherited_params,
236 raw_params,
237 }: HandlerArgsFor<Context, Self>,
238 ) -> Result<Self::Ok, Self::Err> {
239 self.0
240 .handle_async(HandlerArgs {
241 context,
242 parent_method,
243 method,
244 params,
245 inherited_params,
246 raw_params,
247 })
248 .await
249 }
250 fn metadata(&self, method: VecDeque<&'static str>) -> OrdMap<&'static str, Value> {
251 self.0.metadata(method)
252 }
253 fn method_from_dots(&self, method: &str) -> Option<VecDeque<&'static str>> {
254 self.0.method_from_dots(method)
255 }
256}
257impl<Context, H> PrintCliResult<Context> for NoDisplay<H>
258where
259 Context: crate::Context,
260 H: HandlerTypes,
261 H::Params: FromArgMatches + CommandFactory + Serialize,
262{
263 fn print(&self, _: HandlerArgsFor<Context, Self>, _: Self::Ok) -> Result<(), Self::Err> {
264 Ok(())
265 }
266}
267impl<Context, H> CliBindings<Context> for NoDisplay<H>
268where
269 Context: crate::Context,
270 Self: HandlerTypes,
271 Self::Params: CommandFactory + FromArgMatches + Serialize,
272 Self: PrintCliResult<Context>,
273{
274 fn cli_command(&self) -> clap::Command {
275 Self::Params::command()
276 }
277 fn cli_parse(
278 &self,
279 matches: &clap::ArgMatches,
280 ) -> Result<(VecDeque<&'static str>, Value), clap::Error> {
281 Self::Params::from_arg_matches(matches).and_then(|a| {
282 Ok((
283 VecDeque::new(),
284 imbl_value::to_value(&a)
285 .map_err(|e| clap::Error::raw(clap::error::ErrorKind::ValueValidation, e))?,
286 ))
287 })
288 }
289 fn cli_display(
290 &self,
291 handle_args: HandlerArgsFor<Context, Self>,
292 result: Self::Ok,
293 ) -> Result<(), Self::Err> {
294 self.print(handle_args, result)
295 }
296}
297
298#[derive(Clone, Debug)]
299pub struct CustomDisplay<P, H> {
300 print: P,
301 handler: H,
302}
303impl<P, H> HandlerTypes for CustomDisplay<P, H>
304where
305 H: HandlerTypes,
306{
307 type Params = H::Params;
308 type InheritedParams = H::InheritedParams;
309 type Ok = H::Ok;
310 type Err = H::Err;
311}
312
313impl<Context, P, H> HandlerFor<Context> for CustomDisplay<P, H>
314where
315 Context: crate::Context,
316 H: HandlerFor<Context>,
317 P: Send + Sync + Clone + 'static,
318{
319 fn handle_sync(
320 &self,
321 HandlerArgs {
322 context,
323 parent_method,
324 method,
325 params,
326 inherited_params,
327 raw_params,
328 }: HandlerArgsFor<Context, Self>,
329 ) -> Result<Self::Ok, Self::Err> {
330 self.handler.handle_sync(HandlerArgs {
331 context,
332 parent_method,
333 method,
334 params,
335 inherited_params,
336 raw_params,
337 })
338 }
339 async fn handle_async(
340 &self,
341 HandlerArgs {
342 context,
343 parent_method,
344 method,
345 params,
346 inherited_params,
347 raw_params,
348 }: HandlerArgsFor<Context, Self>,
349 ) -> Result<Self::Ok, Self::Err> {
350 self.handler
351 .handle_async(HandlerArgs {
352 context,
353 parent_method,
354 method,
355 params,
356 inherited_params,
357 raw_params,
358 })
359 .await
360 }
361 fn metadata(&self, method: VecDeque<&'static str>) -> OrdMap<&'static str, Value> {
362 self.handler.metadata(method)
363 }
364 fn method_from_dots(&self, method: &str) -> Option<VecDeque<&'static str>> {
365 self.handler.method_from_dots(method)
366 }
367}
368impl<Context, P, H> PrintCliResult<Context> for CustomDisplay<P, H>
369where
370 Context: crate::Context,
371 H: HandlerTypes,
372 P: PrintCliResult<
373 Context,
374 Params = H::Params,
375 InheritedParams = H::InheritedParams,
376 Ok = H::Ok,
377 Err = H::Err,
378 > + Send
379 + Sync
380 + Clone
381 + 'static,
382{
383 fn print(
384 &self,
385 HandlerArgs {
386 context,
387 parent_method,
388 method,
389 params,
390 inherited_params,
391 raw_params,
392 }: HandlerArgsFor<Context, Self>,
393 result: Self::Ok,
394 ) -> Result<(), Self::Err> {
395 self.print.print(
396 HandlerArgs {
397 context,
398 parent_method,
399 method,
400 params,
401 inherited_params,
402 raw_params,
403 },
404 result,
405 )
406 }
407}
408impl<Context, P, H> CliBindings<Context> for CustomDisplay<P, H>
409where
410 Context: crate::Context,
411 Self: HandlerTypes,
412 Self::Params: CommandFactory + FromArgMatches + Serialize,
413 Self: PrintCliResult<Context>,
414{
415 fn cli_command(&self) -> clap::Command {
416 Self::Params::command()
417 }
418 fn cli_parse(
419 &self,
420 matches: &clap::ArgMatches,
421 ) -> Result<(VecDeque<&'static str>, Value), clap::Error> {
422 Self::Params::from_arg_matches(matches).and_then(|a| {
423 Ok((
424 VecDeque::new(),
425 imbl_value::to_value(&a)
426 .map_err(|e| clap::Error::raw(clap::error::ErrorKind::ValueValidation, e))?,
427 ))
428 })
429 }
430 fn cli_display(
431 &self,
432 handle_args: HandlerArgsFor<Context, Self>,
433 result: Self::Ok,
434 ) -> Result<(), Self::Err> {
435 self.print(handle_args, result)
436 }
437}
438
439pub struct CustomDisplayFn<F, H, Context> {
440 _phantom: PhantomData<Context>,
441 print: F,
442 handler: H,
443}
444impl<Context, F: Clone, H: Clone> Clone for CustomDisplayFn<F, H, Context> {
445 fn clone(&self) -> Self {
446 Self {
447 _phantom: PhantomData::new(),
448 print: self.print.clone(),
449 handler: self.handler.clone(),
450 }
451 }
452}
453impl<Context, F: Debug, H: Debug> Debug for CustomDisplayFn<F, H, Context> {
454 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
455 f.debug_struct("CustomDisplayFn")
456 .field("print", &self.print)
457 .field("handler", &self.handler)
458 .finish()
459 }
460}
461impl<F, H, Context> HandlerTypes for CustomDisplayFn<F, H, Context>
462where
463 H: HandlerTypes,
464{
465 type Params = H::Params;
466 type InheritedParams = H::InheritedParams;
467 type Ok = H::Ok;
468 type Err = H::Err;
469}
470
471impl<Context, F, H, C> HandlerFor<Context> for CustomDisplayFn<F, H, C>
472where
473 Context: crate::Context,
474 C: 'static,
475 H: HandlerFor<Context>,
476 F: Send + Sync + Clone + 'static,
477{
478 fn handle_sync(
479 &self,
480 HandlerArgs {
481 context,
482 parent_method,
483 method,
484 params,
485 inherited_params,
486 raw_params,
487 }: HandlerArgsFor<Context, Self>,
488 ) -> Result<Self::Ok, Self::Err> {
489 self.handler.handle_sync(HandlerArgs {
490 context,
491 parent_method,
492 method,
493 params,
494 inherited_params,
495 raw_params,
496 })
497 }
498 async fn handle_async(
499 &self,
500 HandlerArgs {
501 context,
502 parent_method,
503 method,
504 params,
505 inherited_params,
506 raw_params,
507 }: HandlerArgsFor<Context, Self>,
508 ) -> Result<Self::Ok, Self::Err> {
509 self.handler
510 .handle_async(HandlerArgs {
511 context,
512 parent_method,
513 method,
514 params,
515 inherited_params,
516 raw_params,
517 })
518 .await
519 }
520 fn metadata(&self, method: VecDeque<&'static str>) -> OrdMap<&'static str, Value> {
521 self.handler.metadata(method)
522 }
523 fn method_from_dots(&self, method: &str) -> Option<VecDeque<&'static str>> {
524 self.handler.method_from_dots(method)
525 }
526}
527impl<F, H, Context> PrintCliResult<Context> for CustomDisplayFn<F, H, Context>
528where
529 Context: crate::Context,
530 H: HandlerTypes,
531 F: Fn(HandlerArgsFor<Context, H>, H::Ok) -> Result<(), H::Err> + Send + Sync + Clone + 'static,
532{
533 fn print(
534 &self,
535 HandlerArgs {
536 context,
537 parent_method,
538 method,
539 params,
540 inherited_params,
541 raw_params,
542 }: HandlerArgsFor<Context, Self>,
543 result: Self::Ok,
544 ) -> Result<(), Self::Err> {
545 (self.print)(
546 HandlerArgs {
547 context,
548 parent_method,
549 method,
550 params,
551 inherited_params,
552 raw_params,
553 },
554 result,
555 )
556 }
557}
558impl<Context, F, H, C> CliBindings<Context> for CustomDisplayFn<F, H, C>
559where
560 Context: crate::Context,
561 Self: HandlerTypes,
562 Self::Params: CommandFactory + FromArgMatches + Serialize,
563 Self: PrintCliResult<Context>,
564{
565 fn cli_command(&self) -> clap::Command {
566 Self::Params::command()
567 }
568 fn cli_parse(
569 &self,
570 matches: &clap::ArgMatches,
571 ) -> Result<(VecDeque<&'static str>, Value), clap::Error> {
572 Self::Params::from_arg_matches(matches).and_then(|a| {
573 Ok((
574 VecDeque::new(),
575 imbl_value::to_value(&a)
576 .map_err(|e| clap::Error::raw(clap::error::ErrorKind::ValueValidation, e))?,
577 ))
578 })
579 }
580 fn cli_display(
581 &self,
582 handle_args: HandlerArgsFor<Context, Self>,
583 result: Self::Ok,
584 ) -> Result<(), Self::Err> {
585 self.print(handle_args, result)
586 }
587}
588
589pub struct RemoteCaller<Context, RemoteContext, H> {
590 _phantom: PhantomData<(Context, RemoteContext)>,
591 handler: H,
592}
593impl<Context, RemoteContext, H: Clone> Clone for RemoteCaller<Context, RemoteContext, H> {
594 fn clone(&self) -> Self {
595 Self {
596 _phantom: PhantomData::new(),
597 handler: self.handler.clone(),
598 }
599 }
600}
601impl<Context, RemoteContext, H: Debug> Debug for RemoteCaller<Context, RemoteContext, H> {
602 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
603 f.debug_tuple("RemoteCaller").field(&self.handler).finish()
604 }
605}
606
607impl<Context, H, Inherited, RemoteContext> Handler<Inherited>
608 for WithContext<Context, RemoteCaller<Context, RemoteContext, H>>
609where
610 Context: crate::Context + CallRemote<RemoteContext>,
611 RemoteContext: crate::Context,
612 H: HandlerFor<RemoteContext> + CliBindings<Context>,
613 H::Ok: Serialize + DeserializeOwned,
614 H::Err: From<RpcError>,
615 H::Params: Serialize + DeserializeOwned,
616 H::InheritedParams: OrEmpty<Inherited>,
617 RpcError: From<H::Err>,
618 Inherited: Send + Sync + 'static,
619{
620 type H = H;
621 fn handler_for<C: crate::Context>(self) -> Option<DynHandler<C, Inherited>> {
622 if TypeId::of::<C>() == TypeId::of::<RemoteContext>() {
623 DynHandler::new(self.handler.handler.no_cli())
624 } else if TypeId::of::<C>() == TypeId::of::<Context>() {
625 DynHandler::new(CallRemoteHandler::<Context, RemoteContext, _>::new(
626 self.handler.handler,
627 ))
628 } else {
629 None
630 }
631 }
632}
633
634pub struct InheritanceHandler<Params, InheritedParams, H, F> {
635 _phantom: PhantomData<(Params, InheritedParams)>,
636 handler: H,
637 inherit: F,
638}
639impl<Params, InheritedParams, H: Clone, F: Clone> Clone
640 for InheritanceHandler<Params, InheritedParams, H, F>
641{
642 fn clone(&self) -> Self {
643 Self {
644 _phantom: PhantomData::new(),
645 handler: self.handler.clone(),
646 inherit: self.inherit.clone(),
647 }
648 }
649}
650impl<Params, InheritedParams, H: std::fmt::Debug, F> std::fmt::Debug
651 for InheritanceHandler<Params, InheritedParams, H, F>
652{
653 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
654 f.debug_tuple("InheritanceHandler")
655 .field(&self.handler)
656 .finish()
657 }
658}
659impl<Params, InheritedParams, H, F> HandlerTypes
660 for InheritanceHandler<Params, InheritedParams, H, F>
661where
662 H: HandlerTypes,
663 Params: Send + Sync,
664 InheritedParams: Send + Sync,
665{
666 type Params = H::Params;
667 type InheritedParams = Flat<Params, InheritedParams>;
668 type Ok = H::Ok;
669 type Err = H::Err;
670}
671
672impl<Context, Params, InheritedParams, H, F> HandlerFor<Context>
673 for InheritanceHandler<Params, InheritedParams, H, F>
674where
675 Context: crate::Context,
676 Params: Send + Sync + 'static,
677 InheritedParams: Send + Sync + 'static,
678 H: HandlerFor<Context>,
679 F: Fn(Params, InheritedParams) -> H::InheritedParams + Send + Sync + Clone + 'static,
680{
681 fn handle_sync(
682 &self,
683 HandlerArgs {
684 context,
685 parent_method,
686 method,
687 params,
688 inherited_params,
689 raw_params,
690 }: HandlerArgsFor<Context, Self>,
691 ) -> Result<Self::Ok, Self::Err> {
692 self.handler.handle_sync(HandlerArgs {
693 context,
694 parent_method,
695 method,
696 params,
697 inherited_params: (self.inherit)(inherited_params.0, inherited_params.1),
698 raw_params,
699 })
700 }
701 async fn handle_async(
702 &self,
703 HandlerArgs {
704 context,
705 parent_method,
706 method,
707 params,
708 inherited_params,
709 raw_params,
710 }: HandlerArgsFor<Context, Self>,
711 ) -> Result<Self::Ok, Self::Err> {
712 self.handler
713 .handle_async(HandlerArgs {
714 context,
715 parent_method,
716 method,
717 params,
718 inherited_params: (self.inherit)(inherited_params.0, inherited_params.1),
719 raw_params,
720 })
721 .await
722 }
723 fn metadata(&self, method: VecDeque<&'static str>) -> OrdMap<&'static str, Value> {
724 self.handler.metadata(method)
725 }
726 fn method_from_dots(&self, method: &str) -> Option<VecDeque<&'static str>> {
727 self.handler.method_from_dots(method)
728 }
729}
730
731impl<Context, Params, InheritedParams, H, F> CliBindings<Context>
732 for InheritanceHandler<Params, InheritedParams, H, F>
733where
734 Context: crate::Context,
735 Params: Send + Sync + 'static,
736 InheritedParams: Send + Sync + 'static,
737 H: CliBindings<Context>,
738 F: Fn(Params, InheritedParams) -> H::InheritedParams + Send + Sync + Clone + 'static,
739{
740 fn cli_command(&self) -> clap::Command {
741 self.handler.cli_command()
742 }
743 fn cli_parse(
744 &self,
745 matches: &clap::ArgMatches,
746 ) -> Result<(VecDeque<&'static str>, Value), clap::Error> {
747 self.handler.cli_parse(matches)
748 }
749 fn cli_display(
750 &self,
751 HandlerArgs {
752 context,
753 parent_method,
754 method,
755 params,
756 inherited_params,
757 raw_params,
758 }: HandlerArgsFor<Context, Self>,
759 result: Self::Ok,
760 ) -> Result<(), Self::Err> {
761 self.handler.cli_display(
762 HandlerArgs {
763 context,
764 parent_method,
765 method,
766 params,
767 inherited_params: (self.inherit)(inherited_params.0, inherited_params.1),
768 raw_params,
769 },
770 result,
771 )
772 }
773}
774
775#[derive(Debug, Clone)]
776pub struct WithAbout<M, H> {
777 handler: H,
778 message: M,
779}
780impl<M, H> HandlerTypes for WithAbout<M, H>
781where
782 H: HandlerTypes,
783{
784 type Params = H::Params;
785 type InheritedParams = H::InheritedParams;
786 type Ok = H::Ok;
787 type Err = H::Err;
788}
789impl<Context, M, H> HandlerFor<Context> for WithAbout<M, H>
790where
791 Context: crate::Context,
792 H: HandlerFor<Context>,
793 M: Clone + Send + Sync + 'static,
794{
795 fn handle_sync(
796 &self,
797 HandlerArgs {
798 context,
799 parent_method,
800 method,
801 params,
802 inherited_params,
803 raw_params,
804 }: HandlerArgsFor<Context, Self>,
805 ) -> Result<Self::Ok, Self::Err> {
806 self.handler.handle_sync(HandlerArgs {
807 context,
808 parent_method,
809 method,
810 params,
811 inherited_params,
812 raw_params,
813 })
814 }
815 async fn handle_async(
816 &self,
817 HandlerArgs {
818 context,
819 parent_method,
820 method,
821 params,
822 inherited_params,
823 raw_params,
824 }: HandlerArgsFor<Context, Self>,
825 ) -> Result<Self::Ok, Self::Err> {
826 self.handler
827 .handle_async(HandlerArgs {
828 context,
829 parent_method,
830 method,
831 params,
832 inherited_params,
833 raw_params,
834 })
835 .await
836 }
837 fn metadata(&self, method: VecDeque<&'static str>) -> OrdMap<&'static str, Value> {
838 self.handler.metadata(method)
839 }
840 fn method_from_dots(&self, method: &str) -> Option<VecDeque<&'static str>> {
841 self.handler.method_from_dots(method)
842 }
843}
844impl<Context, M, H> CliBindings<Context> for WithAbout<M, H>
845where
846 Context: crate::Context,
847 H: CliBindings<Context>,
848 M: IntoResettable<StyledStr> + Clone,
849{
850 fn cli_command(&self) -> clap::Command {
851 self.handler.cli_command().about(self.message.clone())
852 }
853 fn cli_parse(
854 &self,
855 arg_matches: &clap::ArgMatches,
856 ) -> Result<(VecDeque<&'static str>, Value), clap::Error> {
857 self.handler.cli_parse(arg_matches)
858 }
859 fn cli_display(
860 &self,
861 handler: HandlerArgsFor<Context, Self>,
862 result: Self::Ok,
863 ) -> Result<(), Self::Err> {
864 self.handler.cli_display(handler, result)
865 }
866}