1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use super::BufStream; use bytes::Bytes; use futures::Poll; use std::io; impl BufStream for Bytes { type Item = io::Cursor<Bytes>; type Error = (); fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> { use std::mem; if self.is_empty() { return Ok(None.into()); } let bytes = mem::replace(self, Bytes::new()); let buf = io::Cursor::new(bytes); Ok(Some(buf).into()) } }