Struct chunked_transfer::Encoder
source · pub struct Encoder<W>where
W: Write,{ /* private fields */ }
Expand description
Splits the incoming data into HTTP chunks.
Example
use chunked_transfer::Encoder;
use std::io::Write;
let mut decoded = "hello world";
let mut encoded: Vec<u8> = vec![];
{
let mut encoder = Encoder::with_chunks_size(&mut encoded, 5);
encoder.write_all(decoded.as_bytes());
}
assert_eq!(encoded, b"5\r\nhello\r\n5\r\n worl\r\n1\r\nd\r\n0\r\n\r\n");
Implementations§
source§impl<W> Encoder<W>where
W: Write,
impl<W> Encoder<W>where
W: Write,
Trait Implementations§
source§impl<W> Write for Encoder<W>where
W: Write,
impl<W> Write for Encoder<W>where
W: Write,
source§fn write(&mut self, data: &[u8]) -> IoResult<usize>
fn write(&mut self, data: &[u8]) -> IoResult<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
source§fn flush(&mut self) -> IoResult<()>
fn flush(&mut self) -> IoResult<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<W> RefUnwindSafe for Encoder<W>where
W: RefUnwindSafe,
impl<W> Send for Encoder<W>where
W: Send,
impl<W> Sync for Encoder<W>where
W: Sync,
impl<W> Unpin for Encoder<W>where
W: Unpin,
impl<W> UnwindSafe for Encoder<W>where
W: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more