feat(sdk): Add jumbf_io::remove_jumbf_from_stream - #2452
Open
stupside wants to merge 2 commits into
Open
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2451.
Changes in this pull request
jumbf_iopublishes memory, stream and file forms of load and save, but only the file form of remove:load_jumbf_from_memoryload_jumbf_from_streamload_jumbf_from_filesave_jumbf_to_memorysave_jumbf_to_streamsave_jumbf_to_fileremove_jumbf_from_fileremove_jumbf_from_fileis gated onfile_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 implementsCAIWriter::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_handlerexactly assave_jumbf_to_streamdoes and returningError::UnsupportedTypefor a format with no writer:The doc comment refers to
remove_jumbf_from_filein backticks rather than as an intra-doc link, since that item does not exist in a build withoutfile_ioand the link would dangle there.Checklist
TO DOitems (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-formattest_streams_*tests, already wanted this operation and had no public function to call, so it resolved the handler itself: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_typecovers the dispatch failure, which the per-format tests cannot reach.cargo test -p c2pa --lib jumbf_iois green (21 tests), as arecargo fmtandcargo clippy --all-targets.cargo check --no-default-featurespasses, since being available withoutfile_iois the point of the function.