From a53bf7203cf55284ea509af82f2065e91e66ca4a Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 14 Nov 2026 06:24:19 +0000 Subject: [PATCH] DES-10 T7: AssetData::linked_under turns hash-checked embedded bytes into a link under their key (cherry picked from commit e5599145c5cf80903e41ba74b505b2409bfd1249) --- crates/doc/src/asset_data.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/doc/src/asset_data.rs b/crates/doc/src/asset_data.rs index 67ca3d0fa..483a5bf7c 100644 --- a/crates/doc/src/asset_data.rs +++ b/crates/doc/src/asset_data.rs @@ -132,6 +132,13 @@ impl AssetData { AssetData { key: SourceKey::fresh(), repr: Repr::Linked(Arc::new(Linked { source, trusted: Mutex::new(None) })) } } + /// The linked file `source` names, under `key`: embedded bytes found identical to the file + /// (hash-checked by the caller) become a link without decoding them again. As with + /// [`AssetData::embedded_under`], other bytes under one key would draw stale pixels. + pub fn linked_under(key: SourceKey, source: LinkedSource) -> Self { + AssetData { key, repr: Repr::Linked(Arc::new(Linked { source, trusted: Mutex::new(None) })) } + } + /// This value pointing at `source` (the file moved, the document was saved elsewhere, the /// fingerprint was brought up to date). It keeps the key when both name the same bytes /// (same size and content hash), so nothing decoded is decoded again.