2 releases
Uses old Rust 2015
0.5.1 | Feb 1, 2017 |
---|---|
0.5.0 | Feb 1, 2017 |
#11 in #chunked
4KB
uhttp_chunked_write
This crate implements a zero-copy, zero-allocation writer for HTTP chunked response
bodies. The result can be written
directly into a
TcpStream
or any
other object that implements
Write
.
Example
use uhttp_chunked_write::ChunkedWrite;
use std::io::Write;
let mut buf = [0; 25];
{
let mut body = ChunkedWrite::new(&mut buf[..]);
write!(&mut body, "hello {}", 1337).unwrap();
}
assert_eq!(&buf[..], &b"6\r\nhello \r\n4\r\n1337\r\n0\r\n\r\n"[..]);
Usage
This crate can be used through cargo by
adding it as a dependency in Cargo.toml
:
[dependencies]
uhttp_chunked_write = "0.5.1"
and importing it in the crate root:
extern crate uhttp_chunked_write;