diff --git a/crates/anicraft-format/src/lib.rs b/crates/anicraft-format/src/lib.rs index 7cc5dc261..6ff5d81e1 100644 --- a/crates/anicraft-format/src/lib.rs +++ b/crates/anicraft-format/src/lib.rs @@ -34,7 +34,12 @@ struct EnvelopeOut<'a, P, T> { /// Serializes the envelope in its stable wire order and uses AniCraft's compact/pretty threshold. pub fn write(generator: &str, paths: &[P], document: &T) -> Result { - let envelope = EnvelopeOut { format: FORMAT_NAME, version: FORMAT_VERSION, generator, paths, document }; + write_version(FORMAT_VERSION, generator, paths, document) +} + +/// Serializes the envelope with an explicit format version and AniCraft's compact/pretty threshold. +pub fn write_version(version: u32, generator: &str, paths: &[P], document: &T) -> Result { + let envelope = EnvelopeOut { format: FORMAT_NAME, version, generator, paths, document }; let compact = serde_json::to_string(&envelope)?; if compact.len() < PRETTY_LIMIT { serde_json::to_string_pretty(&envelope) } else { Ok(compact) } }