Skip to main content

changed_paths

Function changed_paths 

Source
pub fn changed_paths<T: Serialize>(
    previous: &T,
    current: &T,
) -> Result<Vec<Change>, Error>
Expand description

The dotted paths that differ between two configuration values.

The audit half of a reload hook: on_reload hands over both structs, and this names what moved — paths only, never values, same as every other diagnostic here.

#[derive(Serialize)]
struct Db { host: String, port: u16 }

let before = Db { host: "a".into(), port: 1 };
let after = Db { host: "a".into(), port: 2 };

let changes = dynamic_config::changed_paths(&before, &after).unwrap();
assert_eq!(changes.len(), 1);
assert_eq!(changes[0].path, "port");

§Errors

If either value does not serialize to a table — a bare scalar has no paths to compare.