Skip to main content

write_json_atomic

Function write_json_atomic 

Source
pub fn write_json_atomic<T: Serialize>(
    path: &Path,
    value: &T,
) -> Result<(), MifRhError>
Expand description

Serializes value to pretty JSON and atomically writes it to path.

Writes to a .tmp sibling, then renames over the destination — so a reader never observes a partially-written file. Shared by review::write_followup, review’s own internal ontology-map.json writer, and mif-rh-cli’s ontology-map.json upsert, which all follow the exact same write-then-rename shape.

§Errors

Returns MifRhError::JsonSerialize if value cannot be serialized, or MifRhError::Io if the temporary file cannot be written or renamed into place.