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

rename service

This commit is contained in:
Nikolay Kim 2018-10-15 16:46:13 -07:00
parent 3c402a55da
commit 20c693b39c
2 changed files with 14 additions and 14 deletions

View File

@ -10,7 +10,7 @@ mod service;
pub use self::codec::{Codec, InMessage, InMessageType, OutMessage};
pub use self::decoder::{PayloadDecoder, RequestDecoder};
pub use self::dispatcher::Dispatcher;
pub use self::service::{H1Service, H1ServiceHandler, H1SimpleService};
pub use self::service::{H1Service, H1ServiceHandler, OneRequest};
use request::Request;

View File

@ -261,23 +261,23 @@ where
}
}
/// `NewService` implementation for `H1SimpleServiceHandler` service
pub struct H1SimpleService<T> {
/// `NewService` implementation for `OneRequestService` service
pub struct OneRequest<T> {
config: ServiceConfig,
_t: PhantomData<T>,
}
impl<T> H1SimpleService<T> {
impl<T> OneRequest<T> {
/// Create new `H1SimpleService` instance.
pub fn new() -> Self {
H1SimpleService {
OneRequest {
config: ServiceConfig::default(),
_t: PhantomData,
}
}
}
impl<T> NewService for H1SimpleService<T>
impl<T> NewService for OneRequest<T>
where
T: AsyncRead + AsyncWrite,
{
@ -285,11 +285,11 @@ where
type Response = (Request, Framed<T, Codec>);
type Error = ParseError;
type InitError = ();
type Service = H1SimpleServiceHandler<T>;
type Service = OneRequestService<T>;
type Future = FutureResult<Self::Service, Self::InitError>;
fn new_service(&self) -> Self::Future {
ok(H1SimpleServiceHandler {
ok(OneRequestService {
config: self.config.clone(),
_t: PhantomData,
})
@ -298,40 +298,40 @@ where
/// `Service` implementation for HTTP1 transport. Reads one request and returns
/// request and framed object.
pub struct H1SimpleServiceHandler<T> {
pub struct OneRequestService<T> {
config: ServiceConfig,
_t: PhantomData<T>,
}
impl<T> Service for H1SimpleServiceHandler<T>
impl<T> Service for OneRequestService<T>
where
T: AsyncRead + AsyncWrite,
{
type Request = T;
type Response = (Request, Framed<T, Codec>);
type Error = ParseError;
type Future = H1SimpleServiceHandlerResponse<T>;
type Future = OneRequestServiceResponse<T>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
Ok(Async::Ready(()))
}
fn call(&mut self, req: Self::Request) -> Self::Future {
H1SimpleServiceHandlerResponse {
OneRequestServiceResponse {
framed: Some(Framed::new(req, Codec::new(self.config.clone()))),
}
}
}
#[doc(hidden)]
pub struct H1SimpleServiceHandlerResponse<T>
pub struct OneRequestServiceResponse<T>
where
T: AsyncRead + AsyncWrite,
{
framed: Option<Framed<T, Codec>>,
}
impl<T> Future for H1SimpleServiceHandlerResponse<T>
impl<T> Future for OneRequestServiceResponse<T>
where
T: AsyncRead + AsyncWrite,
{