diff --git a/src/handler/adapters.rs b/src/handler/adapters.rs index c5cdf8d..a738d6a 100644 --- a/src/handler/adapters.rs +++ b/src/handler/adapters.rs @@ -40,7 +40,7 @@ pub trait HandlerExt: Handler + Sized { ) -> InheritanceHandler where F: Fn(Params, InheritedParams) -> Self::InheritedParams; - fn with_call_remote(self) -> RemoteCaller; + fn with_call_remote(self) -> RemoteCaller; } impl HandlerExt for T { @@ -90,7 +90,7 @@ impl HandlerExt for T { inherit: f, } } - fn with_call_remote(self) -> RemoteCaller { + fn with_call_remote(self) -> RemoteCaller { RemoteCaller { _phantom: PhantomData::new(), handler: self, @@ -452,11 +452,11 @@ where } } -pub struct RemoteCaller { - _phantom: PhantomData<(Context, Extra)>, +pub struct RemoteCaller { + _phantom: PhantomData, handler: H, } -impl Clone for RemoteCaller { +impl Clone for RemoteCaller { fn clone(&self) -> Self { Self { _phantom: PhantomData::new(), @@ -464,31 +464,29 @@ impl Clone for RemoteCaller { } } } -impl Debug for RemoteCaller { +impl Debug for RemoteCaller { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("RemoteCaller").field(&self.handler).finish() } } -impl HandlerTypes for RemoteCaller +impl HandlerTypes for RemoteCaller where H: HandlerTypes, - Extra: Send + Sync + 'static, { - type Params = Flat; + type Params = H::Params; type InheritedParams = H::InheritedParams; type Ok = H::Ok; type Err = H::Err; } -impl Handler for RemoteCaller +impl Handler for RemoteCaller where - Context: CallRemote, + Context: CallRemote, H: Handler, H::Params: Serialize, H::InheritedParams: Serialize, H::Ok: DeserializeOwned, H::Err: From, - Extra: Serialize + Send + Sync + 'static, { type Context = EitherContext; async fn handle_async( @@ -497,7 +495,7 @@ where context, parent_method, method, - params: Flat(params, extra), + params, inherited_params, raw_params, }: HandlerArgsFor, @@ -506,11 +504,7 @@ where EitherContext::C1(context) => { let full_method = parent_method.into_iter().chain(method).collect::>(); match context - .call_remote( - &full_method.join("."), - without(raw_params, &extra).map_err(invalid_params)?, - extra, - ) + .call_remote(&full_method.join("."), raw_params, Empty {}) .await { Ok(a) => imbl_value::from_value(a) @@ -559,7 +553,7 @@ where context, parent_method, method, - params: Flat(params, _), + params, inherited_params, raw_params, }: HandlerArgsFor, diff --git a/tests/handler.rs b/tests/handler.rs index 5eb3929..74ca8a1 100644 --- a/tests/handler.rs +++ b/tests/handler.rs @@ -129,7 +129,7 @@ fn make_api() -> ParentHandler { )) }, ) - .with_call_remote::(), + .with_call_remote::(), ) .subcommand( "hello",