pub struct Updates { /* private fields */ }Expand description
Updates to apply when writing a file
This struct uses a builder pattern where the default is to keep all existing metadata unchanged. Use the builder methods to explicitly specify changes.
§Example
use asset_io::Updates;
// Default: keep everything
let keep = Updates::new();
// Remove XMP, keep everything else
let no_xmp = Updates::new().remove_xmp();
// Set a new C2PA manifest store, remove XMP, keep everything else
let updates = Updates::new()
.set_c2pa(b"new manifest store".to_vec())
.remove_xmp();Implementations§
Source§impl Updates
impl Updates
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new Updates builder with all metadata set to keep (no changes)
This is the same as Updates::default() but more explicit.
Sourcepub fn set_xmp(self, xmp: Vec<u8>) -> Self
pub fn set_xmp(self, xmp: Vec<u8>) -> Self
Set XMP metadata to a new value
§Example
use asset_io::Updates;
let updates = Updates::new().set_xmp(b"<xmp>...</xmp>".to_vec());Sourcepub fn remove_xmp(self) -> Self
pub fn remove_xmp(self) -> Self
Sourcepub fn keep_xmp(self) -> Self
pub fn keep_xmp(self) -> Self
Keep existing XMP metadata (explicit, same as default)
§Example
use asset_io::Updates;
let updates = Updates::new().keep_xmp();Sourcepub fn set_c2pa(self, store: Vec<u8>) -> Self
pub fn set_c2pa(self, store: Vec<u8>) -> Self
Set the C2PA manifest store (a JUMBF superbox) to a new value.
The store replaces the existing one, or is added where the container’s C2PA
embedding puts it. Other JUMBF, which containers such as JPEG may carry
alongside, is left as it is. A container that carries JUMBF of any type
tells a store by its superbox type, so there the store must have the type
C2PA_STORE_TYPE.
§Example
use asset_io::Updates;
let updates = Updates::new().set_c2pa(b"manifest store".to_vec());Sourcepub fn xmp(&self) -> &MetadataUpdate
pub fn xmp(&self) -> &MetadataUpdate
What to do with the XMP.
Sourcepub fn c2pa(&self) -> &MetadataUpdate
pub fn c2pa(&self) -> &MetadataUpdate
What to do with the C2PA manifest store.
Sourcepub fn is_c2pa_update(&self) -> bool
pub fn is_c2pa_update(&self) -> bool
Whether the store being set is an update to the existing store; see
as_update.
Sourcepub fn removes_all(&self) -> bool
pub fn removes_all(&self) -> bool
Whether these updates came from remove_all. A handler
that has options of its own (see extension) treats an
option that was not set as removed then.
Sourcepub fn set_extension<T: Any + Send + Sync>(self, value: T) -> Self
pub fn set_extension<T: Any + Send + Sync>(self, value: T) -> Self
Attach an option that one container defines for itself, such as the merkle boxes of ISO BMFF. One value is kept per type; a later value of the same type replaces the earlier. Containers that do not know the type ignore it. A container that defines an option usually offers builder methods that call this, so callers rarely do.
Sourcepub fn extension<T: Any + Send + Sync>(&self) -> Option<&T>
pub fn extension<T: Any + Send + Sync>(&self) -> Option<&T>
The option of type T, if one was set with
set_extension.
Sourcepub fn clear_extension<T: Any + Send + Sync>(self) -> Self
pub fn clear_extension<T: Any + Send + Sync>(self) -> Self
Forget the option of type T.
Sourcepub fn as_update(self) -> Self
pub fn as_update(self) -> Self
Mark the store given to set_c2pa as an update
manifest added to the existing store: set_c2pa(store).as_update(). Call it
after set_c2pa; a later set_c2pa, remove_c2pa or keep_c2pa
clears it.
Most containers ignore this. A container that keeps the original store apart from later additions (ISO BMFF) uses it: if the new store begins with the existing store’s manifests, byte for byte, it leaves them in place and stores only the rest as an update. Otherwise (nothing to update, or the existing manifests changed) it writes the new store as a whole. The hint is needed because a standard manifest added to a signed file extends the store in the same way, and must not be treated as an update.
Sourcepub fn remove_c2pa(self) -> Self
pub fn remove_c2pa(self) -> Self
Remove the C2PA manifest store. Other JUMBF is kept.
§Example
use asset_io::Updates;
let updates = Updates::new().remove_c2pa();Sourcepub fn keep_c2pa(self) -> Self
pub fn keep_c2pa(self) -> Self
Keep the existing C2PA manifest store (explicit, same as default)
§Example
use asset_io::Updates;
let updates = Updates::new().keep_c2pa();Sourcepub fn keep_all() -> Self
pub fn keep_all() -> Self
Create updates that keep all existing metadata (no changes)
This is an alias for Updates::new() or Updates::default().
Sourcepub fn remove_all() -> Self
pub fn remove_all() -> Self
Create updates that remove all metadata
§Example
use asset_io::Updates;
let updates = Updates::remove_all();Trait Implementations§
Source§impl BmffUpdates for Updates
Available on crate feature bmff only.
impl BmffUpdates for Updates
bmff only.Source§fn set_merkle(self, payloads: Vec<Vec<u8>>) -> Self
fn set_merkle(self, payloads: Vec<Vec<u8>>) -> Self
Source§fn remove_merkle(self) -> Self
fn remove_merkle(self) -> Self
set_merkle.