use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_service::{IntoService, Service}; use actix_utils::framed::{FramedTransport, FramedTransportError}; use super::{Codec, Frame, Message}; pub struct Transport where S: Service + 'static, T: AsyncRead + AsyncWrite, { inner: FramedTransport, } impl Transport where T: AsyncRead + AsyncWrite, S: Service, S::Future: 'static, S::Error: 'static, { pub fn new>(io: T, service: F) -> Self { Transport { inner: FramedTransport::new(Framed::new(io, Codec::new()), service), } } pub fn with>(framed: Framed, service: F) -> Self { Transport { inner: FramedTransport::new(framed, service), } } } impl Future for Transport where T: AsyncRead + AsyncWrite, S: Service, S::Future: 'static, S::Error: 'static, { type Output = Result<(), FramedTransportError>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { Pin::new(&mut self.inner).poll(cx) } }