pub fn content_hash<T: Serialize>(value: &T) -> StringExpand description
Compute a SHA256 hash of a serializable value.
The value is first serialized to JSON, then hashed. This provides a deterministic fingerprint of the content that can be used for:
- Detecting if a record has changed since last export
- Comparing local vs external records during import
§Panics
Panics if the value cannot be serialized to JSON. This should never happen for our data types which are all serializable.
§Example
ⓘ
let session = Session { id: "sess_1".into(), ... };
let hash = content_hash(&session);
// hash is something like "a1b2c3d4..."