diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index 61c284a9c..bff05ab5c 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -19,7 +19,7 @@ use crate::request::Request; use crate::response::Response; use super::codec::Codec; -use super::payload::{Payload, PayloadSender, PayloadStatus, PayloadWriter}; +use super::payload::{Payload, PayloadSender, PayloadStatus}; use super::{Message, MessageType}; const LW_BUFFER_SIZE: usize = 4096; diff --git a/actix-http/src/h1/mod.rs b/actix-http/src/h1/mod.rs index dd29547e5..79d7cda8b 100644 --- a/actix-http/src/h1/mod.rs +++ b/actix-http/src/h1/mod.rs @@ -14,7 +14,7 @@ pub use self::client::{ClientCodec, ClientPayloadCodec}; pub use self::codec::Codec; pub use self::dispatcher::Dispatcher; pub use self::expect::ExpectHandler; -pub use self::payload::{Payload, PayloadWriter}; +pub use self::payload::Payload; pub use self::service::{H1Service, H1ServiceHandler, OneRequest}; #[derive(Debug)] diff --git a/actix-http/src/h1/payload.rs b/actix-http/src/h1/payload.rs index bef87f7dc..e880d46ab 100644 --- a/actix-http/src/h1/payload.rs +++ b/actix-http/src/h1/payload.rs @@ -97,58 +97,35 @@ impl Stream for Payload { } } -impl Clone for Payload { - fn clone(&self) -> Payload { - Payload { - inner: Rc::clone(&self.inner), - } - } -} - -/// Payload writer interface. -pub trait PayloadWriter { - /// Set stream error. - fn set_error(&mut self, err: PayloadError); - - /// Write eof into a stream which closes reading side of a stream. - fn feed_eof(&mut self); - - /// Feed bytes into a payload stream - fn feed_data(&mut self, data: Bytes); - - /// Need read data - fn need_read(&self) -> PayloadStatus; -} - /// Sender part of the payload stream pub struct PayloadSender { inner: Weak>, } -impl PayloadWriter for PayloadSender { +impl PayloadSender { #[inline] - fn set_error(&mut self, err: PayloadError) { + pub fn set_error(&mut self, err: PayloadError) { if let Some(shared) = self.inner.upgrade() { shared.borrow_mut().set_error(err) } } #[inline] - fn feed_eof(&mut self) { + pub fn feed_eof(&mut self) { if let Some(shared) = self.inner.upgrade() { shared.borrow_mut().feed_eof() } } #[inline] - fn feed_data(&mut self, data: Bytes) { + pub fn feed_data(&mut self, data: Bytes) { if let Some(shared) = self.inner.upgrade() { shared.borrow_mut().feed_data(data) } } #[inline] - fn need_read(&self) -> PayloadStatus { + pub fn need_read(&self) -> PayloadStatus { // we check need_read only if Payload (other side) is alive, // otherwise always return true (consume payload) if let Some(shared) = self.inner.upgrade() { diff --git a/actix-multipart/src/server.rs b/actix-multipart/src/server.rs index 39559b082..2dae5fd33 100644 --- a/actix-multipart/src/server.rs +++ b/actix-multipart/src/server.rs @@ -776,7 +776,7 @@ impl PayloadBuffer { #[cfg(test)] mod tests { - use actix_http::h1::{Payload, PayloadWriter}; + use actix_http::h1::Payload; use bytes::Bytes; use futures::unsync::mpsc;