pub fn escaped_bytes(token: &[u8]) -> StringExpand description
bounded_bytes with the escaping applied too, for peer bytes that will be
printed with Display.
The rest of this module divides the work: bounded cuts, and the recording
sigil escapes. That division needs a field to record, and some peer bytes
never get one – a QUIC close reason phrase is inside quinn’s error by the
time this server sees it, and the closing line in crate::quic records the
whole error with %. Escaping at the call site is not available there, and
choosing ? instead would change how every other error on that line reads.
So both rules are applied here instead, once, where the peer’s bytes enter
the value: the result is quoted and Debug-escaped, so a newline in it stays
on the one line and cannot forge a journal entry, and it carries the same
length bound as everything else a peer writes into a log.
assert_eq!(escaped_bytes(b"unexpected frame"), "\"unexpected frame\"");
assert!(!escaped_bytes(b"a\nb").contains('\n'));