Skip to main content

write_word

Function write_word 

Source
pub fn write_word(s: &[u8], out: &mut impl Sink) -> Result<(), WriteError>
Expand description

Writes s as a token when it is a non-empty token, and as a quoted string otherwise (token / quoted-string, RFC 9110 section 5.6.6).

§Errors

As write_quoted.

§Examples

use parse_net::{write::write_word, SliceSink};

let mut buf = [0u8; 32];
let mut out = SliceSink::new(&mut buf);
write_word(b"utf-8", &mut out)?;
write_word(b" ", &mut out)?;
write_word(b"", &mut out)?;
assert_eq!(out.written(), b"utf-8\" \"\"\"");