Skip to content

feat(sdk): Add jumbf_io::remove_jumbf_from_stream - #2452

Open
stupside wants to merge 2 commits into
contentauth:mainfrom
stupside:feat/remove-jumbf-from-stream
Open

feat(sdk): Add jumbf_io::remove_jumbf_from_stream#2452
stupside wants to merge 2 commits into
contentauth:mainfrom
stupside:feat/remove-jumbf-from-stream

Conversation

@stupside

@stupside stupside commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #2451.

Changes in this pull request

jumbf_io publishes memory, stream and file forms of load and save, but only the file form of remove:

memory stream file
load load_jumbf_from_memory load_jumbf_from_stream load_jumbf_from_file
save save_jumbf_to_memory save_jumbf_to_stream save_jumbf_to_file
remove remove_jumbf_from_file

remove_jumbf_from_file is gated on file_io, so with that feature off there is no public way to remove a manifest store at all. The capability is already there: every asset handler implements CAIWriter::remove_cai_store_from_stream, and the file form is a thin dispatch over the path equivalent. Only the public entry point was missing.

This adds the sibling, dispatching through get_caiwriter_handler exactly as save_jumbf_to_stream does and returning Error::UnsupportedType for a format with no writer:

pub fn remove_jumbf_from_stream(
    asset_type: &str,
    input_stream: &mut dyn CAIRead,
    output_stream: &mut dyn CAIReadWrite,
) -> Result<()>

The doc comment refers to remove_jumbf_from_file in backticks rather than as an intra-doc link, since that item does not exist in a build without file_io and the link would dangle there.

Checklist

  • This PR represents a single feature, fix, or change.
  • All applicable changes have been documented.
  • Any TO DO items (or similar) have been entered as GitHub issues and the link to that issue has been included in a comment.

Tests

test_jumbf, the helper behind the per-format test_streams_* tests, already wanted this operation and had no public function to call, so it resolved the handler itself:

let handler = get_caiwriter_handler(asset_type).unwrap();
let mut removed = Cursor::new(Vec::new());
handler
    .remove_cai_store_from_stream(&mut writer, &mut removed)
    .unwrap();

It now calls remove_jumbf_from_stream, so the new function is covered for every format that helper runs: jpeg, png, webp, tiff, svg, mp3, wav, avi, mp4, heif, heic, avif, jxl and c2pa. That replaces the hand-rolled dispatch rather than adding a parallel test for it.

test_remove_jumbf_from_stream_unsupported_type covers the dispatch failure, which the per-format tests cannot reach.

cargo test -p c2pa --lib jumbf_io is green (21 tests), as are cargo fmt and cargo clippy --all-targets. cargo check --no-default-features passes, since being available without file_io is the point of the function.

stupside and others added 2 commits August 7, 2026 22:32
`jumbf_io` publishes memory, stream and file forms of loading and saving a
manifest store, but only the file form of removing one:

              memory                    stream                    file
    load      load_jumbf_from_memory    load_jumbf_from_stream    load_jumbf_from_file
    save      save_jumbf_to_memory      save_jumbf_to_stream      save_jumbf_to_file
    remove                                                        remove_jumbf_from_file

`remove_jumbf_from_file` is gated on the `file_io` feature, so without it there
is no public way to remove a manifest store at all, even though every asset
handler already implements `CAIWriter::remove_cai_store_from_stream` and the
file form is a thin dispatch over the path equivalent.

Add the missing sibling, dispatching through `get_caiwriter_handler` exactly as
`save_jumbf_to_stream` does and returning `Error::UnsupportedType` for a format
with no writer.

The crate's own `test_jumbf` helper was reaching past the public API to do this,
resolving the handler itself and calling `remove_cai_store_from_stream` on it.
It now calls the new function, which covers it for every format that helper runs
(jpeg, png, webp, tiff, svg, mp3, wav, avi, mp4, heif, heic, avif, jxl, c2pa).
`test_remove_jumbf_from_stream_unsupported_type` covers the dispatch failure,
which the per-format tests cannot reach.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jumbf_io has no stream form of remove, so a manifest store cannot be removed without file_io

1 participant