diff --git a/src/payload.rs b/src/payload.rs index e772f3e06..a77bdcba0 100644 --- a/src/payload.rs +++ b/src/payload.rs @@ -2,6 +2,7 @@ use std::{fmt, cmp}; use std::rc::{Rc, Weak}; use std::cell::RefCell; use std::collections::VecDeque; +use std::ops::{Deref, DerefMut}; use bytes::{Bytes, BytesMut}; use futures::{Async, Poll, Stream}; use futures::task::{Task, current as current_task}; @@ -20,6 +21,20 @@ impl ResponseType for PayloadItem { type Error = (); } +impl Deref for PayloadItem { + type Target = Bytes; + + fn deref(&self) -> &Bytes { + &self.0 + } +} + +impl DerefMut for PayloadItem { + fn deref_mut(&mut self) -> &mut Bytes { + &mut self.0 + } +} + impl fmt::Debug for PayloadItem { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&self.0, f)