diff --git a/src/context.rs b/src/context.rs index a86a1fbfc..13eb884cd 100644 --- a/src/context.rs +++ b/src/context.rs @@ -23,7 +23,7 @@ pub trait ActorHttpContext: 'static { #[derive(Debug)] pub enum Frame { - Payload(Option), + Chunk(Option), Drain(oneshot::Sender<()>), } @@ -121,7 +121,7 @@ impl HttpContext where A: Actor { #[inline] pub fn write>(&mut self, data: B) { if !self.disconnected { - self.stream.push_back(Frame::Payload(Some(data.into()))); + self.stream.push_back(Frame::Chunk(Some(data.into()))); } else { warn!("Trying to write to disconnected response"); } @@ -130,7 +130,7 @@ impl HttpContext where A: Actor { /// Indicate end of streamimng payload. Also this method calls `Self::close`. #[inline] pub fn write_eof(&mut self) { - self.stream.push_back(Frame::Payload(None)); + self.stream.push_back(Frame::Chunk(None)); } /// Returns drain future diff --git a/src/pipeline.rs b/src/pipeline.rs index 66be1f55a..77ad05e04 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -209,8 +209,7 @@ struct StartMiddlewares { impl> StartMiddlewares { - fn init(info: &mut PipelineInfo, handler: Rc>) -> PipelineState - { + fn init(info: &mut PipelineInfo, handler: Rc>) -> PipelineState { // execute middlewares, we need this stage because middlewares could be non-async // and we can move to next state immidietly let len = info.mws.len(); @@ -247,8 +246,7 @@ impl> StartMiddlewares { } } - fn poll(&mut self, info: &mut PipelineInfo) -> Option> - { + fn poll(&mut self, info: &mut PipelineInfo) -> Option> { let len = info.mws.len(); 'outer: loop { match self.fut.as_mut().unwrap().poll() { @@ -296,8 +294,7 @@ struct WaitingResponse { impl WaitingResponse { #[inline] - fn init(info: &mut PipelineInfo, reply: Reply) -> PipelineState - { + fn init(info: &mut PipelineInfo, reply: Reply) -> PipelineState { match reply.into() { ReplyItem::Message(resp) => RunMiddlewares::init(info, resp), @@ -307,8 +304,7 @@ impl WaitingResponse { } } - fn poll(&mut self, info: &mut PipelineInfo) -> Option> - { + fn poll(&mut self, info: &mut PipelineInfo) -> Option> { match self.fut.poll() { Ok(Async::NotReady) => None, Ok(Async::Ready(response)) => @@ -329,8 +325,7 @@ struct RunMiddlewares { impl RunMiddlewares { - fn init(info: &mut PipelineInfo, mut resp: HttpResponse) -> PipelineState - { + fn init(info: &mut PipelineInfo, mut resp: HttpResponse) -> PipelineState { if info.count == 0 { return ProcessResponse::init(resp); } @@ -440,8 +435,7 @@ enum IOState { impl ProcessResponse { #[inline] - fn init(resp: HttpResponse) -> PipelineState - { + fn init(resp: HttpResponse) -> PipelineState { PipelineState::Response( ProcessResponse{ resp: resp, iostate: IOState::Response, @@ -513,7 +507,7 @@ impl ProcessResponse { match ctx.poll() { Ok(Async::Ready(Some(frame))) => { match frame { - Frame::Payload(None) => { + Frame::Chunk(None) => { info.context = Some(ctx); self.iostate = IOState::Done; if let Err(err) = io.write_eof() { @@ -523,7 +517,7 @@ impl ProcessResponse { } break }, - Frame::Payload(Some(chunk)) => { + Frame::Chunk(Some(chunk)) => { self.iostate = IOState::Actor(ctx); match io.write(chunk.as_ref()) { Err(err) => { diff --git a/src/ws/context.rs b/src/ws/context.rs index 13cb01c03..d557255dc 100644 --- a/src/ws/context.rs +++ b/src/ws/context.rs @@ -107,7 +107,7 @@ impl WebsocketContext where A: Actor { #[inline] fn write>(&mut self, data: B) { if !self.disconnected { - self.stream.push_back(ContextFrame::Payload(Some(data.into()))); + self.stream.push_back(ContextFrame::Chunk(Some(data.into()))); } else { warn!("Trying to write to disconnected response"); } diff --git a/src/ws/frame.rs b/src/ws/frame.rs index ff2fd188b..823292a98 100644 --- a/src/ws/frame.rs +++ b/src/ws/frame.rs @@ -224,9 +224,7 @@ impl Frame { } /// Write a frame out to a buffer - pub fn format(&mut self, w: &mut W) -> Result<(), Error> - where W: Write - { + pub fn format(&mut self, w: &mut W) -> Result<(), Error> { let mut one = 0u8; let code: u8 = self.opcode.into(); if self.finished {