Skip to main content

null_as_zero

Function null_as_zero 

Source
fn null_as_zero<'de, D>(deserializer: D) -> Result<u64, D::Error>
where D: Deserializer<'de>,
Expand description

Read a counter that may arrive as an explicit null.

serde(default) covers an absent key and not a present-but-null one, so a backend that reports “no caching happened” as null rather than 0 fails the whole frame - and a frame that fails to decode ends the session’s event stream, not just that message. Measured: OpenRouter sends "cache_creation_input_tokens": null for a model with no prompt cache.