pub fn encode_line(value: &impl Serialize) -> StringExpand description
Serializes value to a single JSON-RPC line with no trailing
newline — the caller appends \n when writing it to a stream (matching
decode_line, which also takes one line with the newline already
stripped).
serde_json always escapes control characters, including a literal
\n, inside string values — a well-formed Serialize impl can
therefore never make this produce an embedded newline in the first
place. The debug_assert! below is a belt-and-suspenders guarantee
against a future custom Serialize impl breaking that invariant, not a
runtime check this protocol expects to ever fire.