is_malformed

Function is_malformed 

Source
pub fn is_malformed(payload: &[u8]) -> Result<(), PayloadError>
Expand description

Whether the Datadog Agent would forward the whole serialized DogStatsD payload.

Frames the payload like the Agent’s server.go scanLines, nextMessage, and dropCR. It splits on \n, drops a single trailing \r from each segment so \r\n and \n both work, and skips empty segments, since a blank line is never malformed. The returned index counts every segment, blanks included. An empty or all-blank payload is Ok(()).

The eol-unterminated final-line drop is out of scope: the default dogstatsd_eol_required=[] leaves eol termination off and the generator always \n-terminates.

§Errors

Returns the first PayloadError the Agent would drop on, or Ok(()) when every message forwards.