mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 14:22:39 +00:00
Build: restore designcraft_format::write for recovery; render decodes without naming the image crate
(cherry picked from commit 078f5994c4)
This commit is contained in:
1 parent
1a156fa564
commit
e9f58f5fd0
1 file changed
+10
@@ -36,6 +36,16 @@ pub fn save_with_preview(doc: &Document, preview: Option<&[u8]>) -> Result<Vec<u
|
||||
craft_designcraft_format::save(&compact, concat!("DesignCraft ", env!("CARGO_PKG_VERSION")), preview, &assets)
|
||||
}
|
||||
|
||||
/// [`save_with_preview`] into `out`, in chunks, so a writer that stops on cancellation stops the
|
||||
/// write at its next chunk.
|
||||
pub fn write<W: std::io::Write>(out: &mut W, doc: &Document, preview: Option<&[u8]>) -> Result<(), FormatError> {
|
||||
let bytes = save_with_preview(doc, preview)?;
|
||||
for chunk in bytes.chunks(1 << 20) {
|
||||
out.write_all(chunk).map_err(|e| FormatError::Io(e.to_string()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Required native format version for a document. Kept for app-side compatibility; inference is
|
||||
/// performed by the shared codec over the serialized neutral document schema.
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in new issue
Block a user