pub fn write_datagram(
rng: &mut (impl Rng + ?Sized),
pull: &Pull,
buf: &mut Vec<u8>,
limit_bytes: usize,
) -> DatagramStatsExpand description
Pack one \n-terminated line per context into buf, within limit_bytes, until the room left
cannot hold the smallest context in the pull. Each line is a fresh per-occurrence render against the
room left, so nothing is built and then thrown away, and a context whose line will not fit is passed
over. Clears buf first.
A pull carrying an invalid UTF-8 byte renders that context first, where the whole budget is free, so the byte cannot be lost to a full datagram. The rest are walked from a fresh offset each datagram, so a pull larger than one datagram still puts every context it holds on the wire across the invocation rather than only the ones that happen to sort first.
ยงPanics
Panics when a context whose floor fits the room left produces no line the Agent forwards, and when a pull carrying an invalid UTF-8 byte cannot pack it. Both are generator bugs rather than SUT behaviour, and a quieter datagram or a thinner non-UTF-8 rate would hide them.