use std::collections::VecDeque; use std::fmt::Display; use clap::{CommandFactory, FromArgMatches}; use futures::Future; use imbl_value::imbl::OrdMap; use imbl_value::Value; use serde::de::DeserializeOwned; use serde::Serialize; #[cfg(feature = "ts-rs")] use ts_rs::TS; use crate::util::PhantomData; use crate::{ CliBindings, Empty, HandlerArgs, HandlerArgsFor, HandlerFor, HandlerTypes, PrintCliResult, }; pub struct FromFn { _phantom: PhantomData<(T, E, Args)>, function: F, blocking: bool, metadata: OrdMap<&'static str, Value>, } impl FromFn { pub fn with_metadata(mut self, key: &'static str, value: Value) -> Self { self.metadata.insert(key, value); self } } impl Clone for FromFn { fn clone(&self) -> Self { Self { _phantom: PhantomData::new(), function: self.function.clone(), blocking: self.blocking, metadata: self.metadata.clone(), } } } impl std::fmt::Debug for FromFn { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("FromFn") .field("blocking", &self.blocking) .finish() } } #[cfg(feature = "ts-rs")] impl crate::handler::HandlerTS for FromFn where Self: HandlerTypes, ::Params: ts_rs::TS, ::Ok: ts_rs::TS, { fn type_info(&self) -> Option { Some(format!( "{{_PARAMS:{},_RETURN:{}}}", ::Params::inline(), ::Ok::inline(), )) } } impl PrintCliResult for FromFn where Context: crate::Context, Self: HandlerTypes, ::Ok: Display, { fn print(&self, _: HandlerArgsFor, result: Self::Ok) -> Result<(), Self::Err> { Ok(println!("{result}")) } } impl CliBindings for FromFn where Context: crate::Context, Self: HandlerTypes, Self::Params: CommandFactory + FromArgMatches + Serialize, Self: PrintCliResult, { fn cli_command(&self) -> clap::Command { Self::Params::command() } fn cli_parse( &self, matches: &clap::ArgMatches, ) -> Result<(VecDeque<&'static str>, Value), clap::Error> { Self::Params::from_arg_matches(matches).and_then(|a| { Ok(( VecDeque::new(), imbl_value::to_value(&a) .map_err(|e| clap::Error::raw(clap::error::ErrorKind::ValueValidation, e))?, )) }) } fn cli_display( &self, HandlerArgs { context, parent_method, method, params, inherited_params, raw_params, }: HandlerArgsFor, result: Self::Ok, ) -> Result<(), Self::Err> { self.print( HandlerArgs { context, parent_method, method, params, inherited_params, raw_params, }, result, ) } } pub fn from_fn(function: F) -> FromFn where FromFn: HandlerTypes, { FromFn { function, _phantom: PhantomData::new(), blocking: false, metadata: OrdMap::new(), } } pub fn from_fn_blocking(function: F) -> FromFn where FromFn: HandlerTypes, { FromFn { function, _phantom: PhantomData::new(), blocking: true, metadata: OrdMap::new(), } } pub struct FromFnAsync { _phantom: PhantomData<(Fut, T, E, Args)>, function: F, metadata: OrdMap<&'static str, Value>, } impl FromFnAsync { pub fn with_metadata(mut self, key: &'static str, value: Value) -> Self { self.metadata.insert(key, value); self } } impl Clone for FromFnAsync { fn clone(&self) -> Self { Self { _phantom: PhantomData::new(), function: self.function.clone(), metadata: self.metadata.clone(), } } } impl std::fmt::Debug for FromFnAsync { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("FromFnAsync").finish() } } #[cfg(feature = "ts-rs")] impl crate::handler::HandlerTS for FromFnAsync where Self: HandlerTypes, ::Params: ts_rs::TS, ::Ok: ts_rs::TS, { fn type_info(&self) -> Option { Some(format!( "{{_PARAMS:{},_RETURN:{}}}", ::Params::inline(), ::Ok::inline(), )) } } impl PrintCliResult for FromFnAsync where Context: crate::Context, Self: HandlerTypes, ::Ok: Display, { fn print(&self, _: HandlerArgsFor, result: Self::Ok) -> Result<(), Self::Err> { Ok(println!("{result}")) } } impl CliBindings for FromFnAsync where Context: crate::Context, Self: HandlerTypes, Self::Params: CommandFactory + FromArgMatches + Serialize, Self: PrintCliResult, { fn cli_command(&self) -> clap::Command { Self::Params::command() } fn cli_parse( &self, matches: &clap::ArgMatches, ) -> Result<(VecDeque<&'static str>, Value), clap::Error> { Self::Params::from_arg_matches(matches).and_then(|a| { Ok(( VecDeque::new(), imbl_value::to_value(&a) .map_err(|e| clap::Error::raw(clap::error::ErrorKind::ValueValidation, e))?, )) }) } fn cli_display( &self, HandlerArgs { context, parent_method, method, params, inherited_params, raw_params, }: HandlerArgsFor, result: Self::Ok, ) -> Result<(), Self::Err> { self.print( HandlerArgs { context, parent_method, method, params, inherited_params, raw_params, }, result, ) } } pub fn from_fn_async(function: F) -> FromFnAsync where FromFnAsync: HandlerTypes, { FromFnAsync { function, _phantom: PhantomData::new(), metadata: OrdMap::new(), } } pub struct FromFnAsyncLocal { _phantom: PhantomData<(Fut, T, E, Args)>, function: F, metadata: OrdMap<&'static str, Value>, } impl FromFnAsyncLocal { pub fn with_metadata(mut self, key: &'static str, value: Value) -> Self { self.metadata.insert(key, value); self } } impl Clone for FromFnAsyncLocal { fn clone(&self) -> Self { Self { _phantom: PhantomData::new(), function: self.function.clone(), metadata: self.metadata.clone(), } } } impl std::fmt::Debug for FromFnAsyncLocal { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("FromFnAsyncLocal").finish() } } #[cfg(feature = "ts-rs")] impl crate::handler::HandlerTS for FromFnAsyncLocal where Self: HandlerTypes, ::Params: ts_rs::TS, ::Ok: ts_rs::TS, { fn type_info(&self) -> Option { Some(format!( "{{_PARAMS:{},_RETURN:{}}}", ::Params::inline(), ::Ok::inline(), )) } } impl PrintCliResult for FromFnAsyncLocal where Context: crate::Context, Self: HandlerTypes, ::Ok: Display, { fn print(&self, _: HandlerArgsFor, result: Self::Ok) -> Result<(), Self::Err> { Ok(println!("{result}")) } } impl CliBindings for FromFnAsyncLocal where Context: crate::Context, Self: HandlerTypes, Self::Params: CommandFactory + FromArgMatches + Serialize, Self: PrintCliResult, { fn cli_command(&self) -> clap::Command { Self::Params::command() } fn cli_parse( &self, matches: &clap::ArgMatches, ) -> Result<(VecDeque<&'static str>, Value), clap::Error> { Self::Params::from_arg_matches(matches).and_then(|a| { Ok(( VecDeque::new(), imbl_value::to_value(&a) .map_err(|e| clap::Error::raw(clap::error::ErrorKind::ValueValidation, e))?, )) }) } fn cli_display( &self, HandlerArgs { context, parent_method, method, params, inherited_params, raw_params, }: HandlerArgsFor, result: Self::Ok, ) -> Result<(), Self::Err> { self.print( HandlerArgs { context, parent_method, method, params, inherited_params, raw_params, }, result, ) } } pub fn from_fn_async_local(function: F) -> FromFnAsyncLocal where FromFnAsyncLocal: HandlerTypes, { FromFnAsyncLocal { function, _phantom: PhantomData::new(), metadata: OrdMap::new(), } } impl HandlerTypes for FromFn> where F: Fn(HandlerArgs) -> Result + Send + Sync + Clone + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, Context: crate::Context, Params: Send + Sync, InheritedParams: Send + Sync, { type Params = Params; type InheritedParams = InheritedParams; type Ok = T; type Err = E; } impl HandlerFor for FromFn> where Self: crate::handler::HandlerRequires< Params = Params, InheritedParams = InheritedParams, Ok = T, Err = E, >, F: Fn(HandlerArgs) -> Result + Send + Sync + Clone + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, Context: crate::Context, Params: Send + Sync + 'static, InheritedParams: Send + Sync + 'static, { fn handle_sync( &self, handle_args: HandlerArgsFor, ) -> Result { (self.function)(handle_args) } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { if self.blocking { self.handle_async_with_sync_blocking(handle_args).await } else { self.handle_async_with_sync(handle_args).await } } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsync> where F: Fn(HandlerArgs) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, Context: crate::Context, Params: Send + Sync, InheritedParams: Send + Sync, { type Params = Params; type InheritedParams = InheritedParams; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsync> where Self: crate::handler::HandlerRequires< Params = Params, InheritedParams = InheritedParams, Ok = T, Err = E, >, F: Fn(HandlerArgs) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, Context: crate::Context, Params: Send + Sync + 'static, InheritedParams: Send + Sync + 'static, { async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { (self.function)(handle_args).await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFn where F: Fn() -> Result + Send + Sync + Clone + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Empty; type InheritedParams = Empty; type Ok = T; type Err = E; } impl HandlerFor for FromFn where Self: crate::handler::HandlerRequires, Context: crate::Context, F: Fn() -> Result + Send + Sync + Clone + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { fn handle_sync(&self, _: HandlerArgsFor) -> Result { (self.function)() } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { if self.blocking { self.handle_async_with_sync_blocking(handle_args).await } else { self.handle_async_with_sync(handle_args).await } } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsync where F: Fn() -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Empty; type InheritedParams = Empty; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsync where Self: crate::handler::HandlerRequires, Context: crate::Context, F: Fn() -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { async fn handle_async(&self, _: HandlerArgsFor) -> Result { (self.function)().await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFn where Context: crate::Context, F: Fn(Context) -> Result + Send + Sync + Clone + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Empty; type InheritedParams = Empty; type Ok = T; type Err = E; } impl HandlerFor for FromFn where Self: crate::handler::HandlerRequires, Context: crate::Context, F: Fn(Context) -> Result + Send + Sync + Clone + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { fn handle_sync( &self, handle_args: HandlerArgsFor, ) -> Result { (self.function)(handle_args.context) } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { if self.blocking { self.handle_async_with_sync_blocking(handle_args).await } else { self.handle_async_with_sync(handle_args).await } } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsync where Context: crate::Context, F: Fn(Context) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Empty; type InheritedParams = Empty; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsync where Self: crate::handler::HandlerRequires, Context: crate::Context, F: Fn(Context) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { (self.function)(handle_args.context).await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFn where Context: crate::Context, F: Fn(Context, Params) -> Result + Send + Sync + Clone + 'static, Params: DeserializeOwned + Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Params; type InheritedParams = Empty; type Ok = T; type Err = E; } impl HandlerFor for FromFn where Self: crate::handler::HandlerRequires, Context: crate::Context, F: Fn(Context, Params) -> Result + Send + Sync + Clone + 'static, Params: DeserializeOwned + Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { fn handle_sync( &self, handle_args: HandlerArgsFor, ) -> Result { let HandlerArgs { context, params, .. } = handle_args; (self.function)(context, params) } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { if self.blocking { self.handle_async_with_sync_blocking(handle_args).await } else { self.handle_async_with_sync(handle_args).await } } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsync where Context: crate::Context, F: Fn(Context, Params) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, Params: DeserializeOwned + Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Params; type InheritedParams = Empty; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsync where Self: crate::handler::HandlerRequires, Context: crate::Context, F: Fn(Context, Params) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, Params: DeserializeOwned + Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { let HandlerArgs { context, params, .. } = handle_args; (self.function)(context, params).await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFn where Context: crate::Context, F: Fn(Context, Params, InheritedParams) -> Result + Send + Sync + Clone + 'static, Params: DeserializeOwned + Send + Sync + 'static, InheritedParams: Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Params; type InheritedParams = InheritedParams; type Ok = T; type Err = E; } impl HandlerFor for FromFn where Self: crate::handler::HandlerRequires< Params = Params, InheritedParams = InheritedParams, Ok = T, Err = E, >, Context: crate::Context, F: Fn(Context, Params, InheritedParams) -> Result + Send + Sync + Clone + 'static, Params: DeserializeOwned + Send + Sync + 'static, InheritedParams: Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { fn handle_sync( &self, handle_args: HandlerArgsFor, ) -> Result { let HandlerArgs { context, params, inherited_params, .. } = handle_args; (self.function)(context, params, inherited_params) } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { if self.blocking { self.handle_async_with_sync_blocking(handle_args).await } else { self.handle_async_with_sync(handle_args).await } } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsync where Context: crate::Context, F: Fn(Context, Params, InheritedParams) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, Params: DeserializeOwned + Send + Sync + 'static, InheritedParams: Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Params; type InheritedParams = InheritedParams; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsync where Self: crate::handler::HandlerRequires< Params = Params, InheritedParams = InheritedParams, Ok = T, Err = E, >, Context: crate::Context, F: Fn(Context, Params, InheritedParams) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + Send + 'static, Params: DeserializeOwned + Send + Sync + 'static, InheritedParams: Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { let HandlerArgs { context, params, inherited_params, .. } = handle_args; (self.function)(context, params, inherited_params).await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsyncLocal> where F: Fn(HandlerArgs) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, Context: crate::Context, Params: Send + Sync, InheritedParams: Send + Sync, { type Params = Params; type InheritedParams = InheritedParams; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsyncLocal> where Self: crate::handler::HandlerRequires< Params = Params, InheritedParams = InheritedParams, Ok = T, Err = E, >, F: Fn(HandlerArgs) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, Context: crate::Context, Params: Send + Sync + 'static, InheritedParams: Send + Sync + 'static, { fn handle_sync( &self, handle_args: HandlerArgsFor, ) -> Result { let local = tokio::task::LocalSet::new(); if let Some(rt) = handle_args.context.runtime() { local.block_on(&*rt, (self.function)(handle_args)) } else { tokio::runtime::Handle::current() .block_on(local.run_until((self.function)(handle_args))) } } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { self.handle_async_with_sync_blocking(handle_args).await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsyncLocal where F: Fn() -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Empty; type InheritedParams = Empty; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsyncLocal where Self: crate::handler::HandlerRequires, Context: crate::Context, F: Fn() -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { fn handle_sync( &self, handle_args: HandlerArgsFor, ) -> Result { let local = tokio::task::LocalSet::new(); if let Some(rt) = handle_args.context.runtime() { local.block_on(&*rt, (self.function)()) } else { tokio::runtime::Handle::current().block_on(local.run_until((self.function)())) } } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { self.handle_async_with_sync_blocking(handle_args).await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsyncLocal where Context: crate::Context, F: Fn(Context) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Empty; type InheritedParams = Empty; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsyncLocal where Self: crate::handler::HandlerRequires, Context: crate::Context, F: Fn(Context) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { fn handle_sync( &self, handle_args: HandlerArgsFor, ) -> Result { let local = tokio::task::LocalSet::new(); if let Some(rt) = handle_args.context.runtime() { local.block_on(&*rt, (self.function)(handle_args.context)) } else { tokio::runtime::Handle::current() .block_on(local.run_until((self.function)(handle_args.context))) } } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { self.handle_async_with_sync_blocking(handle_args).await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsyncLocal where Context: crate::Context, F: Fn(Context, Params) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, Params: DeserializeOwned + Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Params; type InheritedParams = Empty; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsyncLocal where Self: crate::handler::HandlerRequires, Context: crate::Context, F: Fn(Context, Params) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, Params: DeserializeOwned + Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { fn handle_sync( &self, handle_args: HandlerArgsFor, ) -> Result { let local = tokio::task::LocalSet::new(); if let Some(rt) = handle_args.context.runtime() { local.block_on( &*rt, (self.function)(handle_args.context, handle_args.params), ) } else { tokio::runtime::Handle::current() .block_on(local.run_until((self.function)(handle_args.context, handle_args.params))) } } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { self.handle_async_with_sync_blocking(handle_args).await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } } impl HandlerTypes for FromFnAsyncLocal where Context: crate::Context, F: Fn(Context, Params, InheritedParams) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, Params: DeserializeOwned + Send + Sync + 'static, InheritedParams: Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { type Params = Params; type InheritedParams = InheritedParams; type Ok = T; type Err = E; } impl HandlerFor for FromFnAsyncLocal where Self: crate::handler::HandlerRequires< Params = Params, InheritedParams = InheritedParams, Ok = T, Err = E, >, Context: crate::Context, F: Fn(Context, Params, InheritedParams) -> Fut + Send + Sync + Clone + 'static, Fut: Future> + 'static, Params: DeserializeOwned + Send + Sync + 'static, InheritedParams: Send + Sync + 'static, T: Send + Sync + 'static, E: Send + Sync + 'static, { fn handle_sync( &self, handle_args: HandlerArgsFor, ) -> Result { let local = tokio::task::LocalSet::new(); if let Some(rt) = handle_args.context.runtime() { local.block_on( &*rt, (self.function)( handle_args.context, handle_args.params, handle_args.inherited_params, ), ) } else { tokio::runtime::Handle::current().block_on(local.run_until((self.function)( handle_args.context, handle_args.params, handle_args.inherited_params, ))) } } async fn handle_async( &self, handle_args: HandlerArgsFor, ) -> Result { self.handle_async_with_sync_blocking(handle_args).await } fn metadata(&self, _: VecDeque<&'static str>) -> OrdMap<&'static str, Value> { self.metadata.clone() } }