Skip to main content

declares_baseline_format

Function declares_baseline_format 

Source
pub fn declares_baseline_format(json: &str, declared_keys: &[&str]) -> bool
Expand description

Whether a baseline file is written in the format it was loaded as.

The duplication and health formats give every field a serde default, so a baseline another command saved, and an object with nothing in it, both deserialize into zero entries and are indistinguishable from this command’s own baseline saved from a project that had nothing to record. Asking which keys the file actually carries separates them: a file that declares at least one key of the format it was read as is that command’s baseline, however empty it is.

False for anything that is not a JSON object, including a file this crate would refuse to deserialize; those paths report their own error before a caller gets here.