pub struct Encoder { /* private fields */ }Expand description
Caller-owned wire buffer, reused across commands. No body buffering.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn start(head: &Head, body: BodyLength, out: &mut Vec<u8>) -> Result<Self>
pub fn start(head: &Head, body: BodyLength, out: &mut Vec<u8>) -> Result<Self>
Encode a head. A response’s status line uses the canonical reason
phrase; start_with_reason sets another one.
Sourcepub fn start_with_reason(
head: &Head,
reason: &str,
body: BodyLength,
out: &mut Vec<u8>,
) -> Result<Self>
pub fn start_with_reason( head: &Head, reason: &str, body: BodyLength, out: &mut Vec<u8>, ) -> Result<Self>
Encode a response head with a custom reason phrase, as Node’s
res.writeHead(404, "Nope") puts HTTP/1.1 404 Nope on the wire. The
phrase may be empty, and may hold spaces, tabs, visible ASCII and
obs-text (RFC 9112 section 4); a request head or a control character is
refused before anything is written.
pub fn body(&mut self, bytes: &[u8], out: &mut Vec<u8>) -> Result<()>
pub fn finish(&mut self, trailers: &[Header], out: &mut Vec<u8>) -> Result<()>
Auto Trait Implementations§
impl Forget for Encoder
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnsafeUnpin for Encoder
impl UnwindSafe for Encoder
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