use futures_util::Future; use giterated_models::error::OperationError; use crate::{HandlerResolvable, IntoGiteratedHandler}; #[async_trait::async_trait(?Send)] impl IntoGiteratedHandler<(R1,), (), S, OS, Result>> for H where H: FnMut(R1, S, OS) -> Fut + Clone, Fut: Future>> + 'static, Success: 'static, Failure: 'static, R1: 'static, S: 'static, OS: 'static, { type Future = Fut; async fn handle( &self, parameters: (R1,), state: S, operation_state: OS, ) -> Result> { let (r1,) = parameters; (self.clone())(r1, state, operation_state).await } } #[async_trait::async_trait(?Send)] impl IntoGiteratedHandler<(R1,), (A1,), S, OS, Result>> for H where H: FnMut(R1, S, OS, A1) -> Fut + Clone, Fut: Future>> + 'static, Success: 'static, Failure: 'static, R1: 'static, S: 'static, OS: 'static, A1: HandlerResolvable<(R1,), OS>, A1::Error: Into, { type Future = Fut; async fn handle( &self, parameters: (R1,), state: S, operation_state: OS, ) -> Result> { let a1 = A1::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let (r1,) = parameters; (self.clone())(r1, state, operation_state, a1).await } } #[async_trait::async_trait(?Send)] impl IntoGiteratedHandler<(R1,), (A1, A2), S, OS, Result>> for H where H: FnMut(R1, S, OS, A1, A2) -> Fut + Clone, Fut: Future>> + 'static, Success: 'static, Failure: 'static, R1: 'static, S: 'static, OS: 'static, A1: HandlerResolvable<(R1,), OS>, A1::Error: Into, A2: HandlerResolvable<(R1,), OS>, A2::Error: Into, { type Future = Fut; async fn handle( &self, parameters: (R1,), state: S, operation_state: OS, ) -> Result> { let a1 = A1::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let a2 = A2::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let (r1,) = parameters; (self.clone())(r1, state, operation_state, a1, a2).await } } #[async_trait::async_trait(?Send)] impl IntoGiteratedHandler<(R1,), (A1, A2, A3), S, OS, Result>> for H where H: FnMut(R1, S, OS, A1, A2, A3) -> Fut + Clone, Fut: Future>> + 'static, Success: 'static, Failure: 'static, R1: 'static, S: 'static, OS: 'static, A1: HandlerResolvable<(R1,), OS>, A1::Error: Into, A2: HandlerResolvable<(R1,), OS>, A2::Error: Into, A3: HandlerResolvable<(R1,), OS>, A3::Error: Into, { type Future = Fut; async fn handle( &self, parameters: (R1,), state: S, operation_state: OS, ) -> Result> { let a1 = A1::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let a2 = A2::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let a3 = A3::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let (r1,) = parameters; (self.clone())(r1, state, operation_state, a1, a2, a3).await } } #[async_trait::async_trait(?Send)] impl IntoGiteratedHandler<(R1, R2), (), S, OS, Result>> for H where H: FnMut(R1, R2, S, OS) -> Fut + Clone, Fut: Future>> + 'static, Success: 'static, Failure: 'static, R1: 'static, R2: 'static, S: 'static, OS: 'static, { type Future = Fut; async fn handle( &self, parameters: (R1, R2), state: S, operation_state: OS, ) -> Result> { let (r1, r2) = parameters; (self.clone())(r1, r2, state, operation_state).await } } #[async_trait::async_trait(?Send)] impl IntoGiteratedHandler<(R1, R2), (A1,), S, OS, Result>> for H where H: FnMut(R1, R2, S, OS, A1) -> Fut + Clone, Fut: Future>> + 'static, Success: 'static, Failure: 'static, R1: 'static, R2: 'static, S: 'static, OS: 'static, A1: HandlerResolvable<(R1, R2), OS>, A1::Error: Into, { type Future = Fut; async fn handle( &self, parameters: (R1, R2), state: S, operation_state: OS, ) -> Result> { let a1 = A1::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let (r1, r2) = parameters; (self.clone())(r1, r2, state, operation_state, a1).await } } #[async_trait::async_trait(?Send)] impl IntoGiteratedHandler<(R1, R2), (A1, A2), S, OS, Result>> for H where H: FnMut(R1, R2, S, OS, A1, A2) -> Fut + Clone, Fut: Future>> + 'static, Success: 'static, Failure: 'static, R1: 'static, R2: 'static, S: 'static, OS: 'static, A1: HandlerResolvable<(R1, R2), OS>, A1::Error: Into, A2: HandlerResolvable<(R1, R2), OS>, A2::Error: Into, { type Future = Fut; async fn handle( &self, parameters: (R1, R2), state: S, operation_state: OS, ) -> Result> { let a1 = A1::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let a2 = A2::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let (r1, r2) = parameters; (self.clone())(r1, r2, state, operation_state, a1, a2).await } } #[async_trait::async_trait(?Send)] impl IntoGiteratedHandler<(R1, R2), (A1, A2, A3), S, OS, Result>> for H where H: FnMut(R1, R2, S, OS, A1, A2, A3) -> Fut + Clone, Fut: Future>> + 'static, Success: 'static, Failure: 'static, R1: 'static, R2: 'static, S: 'static, OS: 'static, A1: HandlerResolvable<(R1, R2), OS>, A1::Error: Into, A2: HandlerResolvable<(R1, R2), OS>, A2::Error: Into, A3: HandlerResolvable<(R1, R2), OS>, A3::Error: Into, { type Future = Fut; async fn handle( &self, parameters: (R1, R2), state: S, operation_state: OS, ) -> Result> { let a1 = A1::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let a2 = A2::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let a3 = A3::from_handler_state(¶meters, &operation_state) .await .map_err(|e| OperationError::Internal(e.into()))?; let (r1, r2) = parameters; (self.clone())(r1, r2, state, operation_state, a1, a2, a3).await } }