1use std::task::{Context, Poll};
2
3use actori_service::{Service, ServiceFactory};
4use futures_util::future::{ok, Ready};
5
6use crate::error::Error;
7use crate::request::Request;
8
9pub struct ExpectHandler;
10
11impl ServiceFactory for ExpectHandler {
12 type Config = ();
13 type Request = Request;
14 type Response = Request;
15 type Error = Error;
16 type Service = ExpectHandler;
17 type InitError = Error;
18 type Future = Ready<Result<Self::Service, Self::InitError>>;
19
20 fn new_service(&self, _: ()) -> Self::Future {
21 ok(ExpectHandler)
22 }
23}
24
25impl Service for ExpectHandler {
26 type Request = Request;
27 type Response = Request;
28 type Error = Error;
29 type Future = Ready<Result<Self::Response, Self::Error>>;
30
31 fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
32 Poll::Ready(Ok(()))
33 }
34
35 fn call(&mut self, req: Request) -> Self::Future {
36 ok(req)
37 }
38}