Expand description
Output: the Sink trait, SliceSink, CountSink, and the writers
for numbers, tokens, quoted strings, parameters, and field values.
Every writer validates all of its input before the first
put, and checks remaining when its
output takes several put calls, so after any error a SliceSink holds
exactly what it held before. No writer can emit CR, LF, or NUL, and no
writer produces a value its own parser would refuse.
§Examples
use parse_net::{self as pn, write};
let mut buf = [0u8; 64];
let mut out = pn::SliceSink::new(&mut buf);
write::write_word(b"gzip", &mut out)?;
write::write_param(b"title", b"say \"hi\"", &mut out)?;
assert_eq!(out.written(), b"gzip; title=\"say \\\"hi\\\"\"");
assert_eq!(write::write_quoted(b"a\nb", &mut out), Err(pn::WriteError::Forbidden { at: 1 }));Structs§
- Count
Sink - A sink that counts bytes and writes nothing.
- Full
- A sink has no room for the bytes it was given.
- Slice
Sink - A cursor over a caller buffer.
Traits§
- Sink
- The output abstraction every writer takes.
Functions§
- write_
decimal_ u64 - Writes
nin decimal, with no sign and no padding. - write_
field_ value - Writes
sas a field value, after checking every byte isfield-vchar, SP, HTAB, orobs-text. - write_
hex_ u64 - Writes
nin lowercase hexadecimal, with no prefix and no padding. - write_
param - Writes
; name=value, the value throughwrite_word. - write_
quoted - Writes
sas a quoted string. - write_
token - Writes
sas a token, after checking it is one. - write_
word - Writes
sas a token when it is a non-empty token, and as a quoted string otherwise (token / quoted-string, RFC 9110 section 5.6.6).