prosa_hyper/client/
adaptor.rs1use std::convert::Infallible;
2
3use bytes::Bytes;
4use http_body_util::combinators::BoxBody;
5use hyper::{Request, Response};
6use prosa::core::{error::ProcError, service::ServiceError};
7use url::Url;
8
9use crate::client::proc::HyperClientProc;
10
11#[cfg_attr(doc, aquamarine::aquamarine)]
12pub trait HyperClientAdaptor<M>
23where
24 M: 'static
25 + std::marker::Send
26 + std::marker::Sync
27 + std::marker::Sized
28 + std::clone::Clone
29 + std::fmt::Debug
30 + prosa::core::msg::Tvf
31 + std::default::Default,
32{
33 fn new(proc: &HyperClientProc<M>) -> Result<Self, Box<dyn ProcError + Send + Sync>>
35 where
36 Self: Sized;
37
38 fn process_srv_request(
40 &self,
41 request: M,
42 socket_url: &Url,
43 ) -> Result<Request<BoxBody<Bytes, Infallible>>, ServiceError>;
44
45 fn process_http_response(
47 &self,
48 resp: Result<Response<hyper::body::Incoming>, hyper::Error>,
49 ) -> impl std::future::Future<Output = Result<M, ServiceError>> + Send;
50}