Skip to main content

decode_with_warnings

Function decode_with_warnings 

Source
pub fn decode_with_warnings(body: &[u8]) -> Result<(RunAgentInput, Vec<String>)>
Expand description

decode, also returning a warning for each thing it removed or read as omitted: an unrecognised field or enum member, a deprecated optional null. Each quotes at most 64 characters of the body, with control characters escaped. Nothing in this crate prints them; where they go is the caller’s choice.

let (input, warnings) = decode_with_warnings(
    br#"{"threadId":"t","runId":"r","messages":[],"somethingNewer":1}"#,
)?;
assert_eq!(input.run_id.as_str(), "r");
assert_eq!(warnings, ["unrecognised property at /somethingNewer"]);