1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-24 01:11:07 +01:00

remove uneeded code

This commit is contained in:
Nikolay Kim 2019-03-08 20:10:47 -08:00
parent 7db29544f9
commit 0f064c43e9

View File

@ -1,11 +1,7 @@
use std::cell::Cell;
use std::marker::PhantomData;
use std::net::SocketAddr;
use std::rc::Rc;
use actix_service::{FnService, IntoService, NewService};
use futures::future::{ok, FutureResult, IntoFuture};
#[derive(Debug, Clone)]
pub struct ServerConfig {
addr: SocketAddr,
@ -35,54 +31,3 @@ impl ServerConfig {
self.secure.as_ref().set(true)
}
}
pub fn server_fn<F, U, Req, Out>(f: F) -> impl NewService<Req, ServerConfig>
where
F: Fn(&ServerConfig) -> U + Clone + 'static,
U: FnMut(Req) -> Out + Clone + 'static,
Out: IntoFuture,
{
ServerFnNewService { f, _t: PhantomData }
}
struct ServerFnNewService<F, U, Req, Out>
where
F: Fn(&ServerConfig) -> U + Clone + 'static,
U: FnMut(Req) -> Out + Clone + 'static,
Out: IntoFuture,
{
f: F,
_t: PhantomData<(U, Req, Out)>,
}
impl<F, U, Req, Out> NewService<Req, ServerConfig> for ServerFnNewService<F, U, Req, Out>
where
F: Fn(&ServerConfig) -> U + Clone + 'static,
U: FnMut(Req) -> Out + Clone + 'static,
Out: IntoFuture,
{
type Response = Out::Item;
type Error = Out::Error;
type Service = FnService<U, Req, Out>;
type InitError = ();
type Future = FutureResult<Self::Service, Self::InitError>;
fn new_service(&self, cfg: &ServerConfig) -> Self::Future {
ok((self.f)(cfg).into_service())
}
}
impl<F, U, Req, Out> Clone for ServerFnNewService<F, U, Req, Out>
where
F: Fn(&ServerConfig) -> U + Clone + 'static,
U: FnMut(Req) -> Out + Clone,
Out: IntoFuture,
{
fn clone(&self) -> Self {
Self {
f: self.f.clone(),
_t: PhantomData,
}
}
}