Skip to main content

hash_api

Function hash_api 

Source
pub fn hash_api(api: &Api) -> String
Expand description

Serialize the API to canonical JSON and return its SHA-256 hex digest.

The IR is first serialized to a serde_json::Value, whose Object representation is backed by a BTreeMap (when the preserve_order feature is not enabled). Re-serializing that Value therefore emits keys in deterministic, lexicographic order regardless of the iteration order of any source maps. This guarantees that two runs over the same IR always produce the same hash.

ยงPanics

Panics if api cannot be serialized to JSON. This does not happen for a well-formed Api, whose IR is plain serializable data.