use xitca_service::Service;
use super::service::{H3Service, H3ServiceV2};
pub struct H3ServiceBuilder;
impl Default for H3ServiceBuilder {
fn default() -> Self {
Self::new()
}
}
impl H3ServiceBuilder {
pub fn new() -> Self {
H3ServiceBuilder
}
}
impl<S, E> Service<Result<S, E>> for H3ServiceBuilder {
type Response = H3Service<S>;
type Error = E;
async fn call(&self, res: Result<S, E>) -> Result<Self::Response, Self::Error> {
res.map(H3Service::new)
}
}
pub struct H3ServiceBuilderV2;
impl Default for H3ServiceBuilderV2 {
fn default() -> Self {
Self::new()
}
}
impl H3ServiceBuilderV2 {
pub fn new() -> Self {
H3ServiceBuilderV2
}
}
impl<S, E> Service<Result<S, E>> for H3ServiceBuilderV2 {
type Response = H3ServiceV2<S>;
type Error = E;
async fn call(&self, res: Result<S, E>) -> Result<Self::Response, Self::Error> {
res.map(H3ServiceV2::new)
}
}