feat: Adds Progress and Cancel API support#195
Merged
Conversation
Exposes the progress/cancel feature added to c2pa-rs in PR #1927 (merged to main 2026-03-24, not yet on crates.io). Public API additions (c2pa.hpp): - `c2pa::ProgressCallbackFunc` — std::function alias for the callback. Signature: `bool(C2paProgressPhase phase, uint32_t step, uint32_t total)`. Return false to request cancellation. - `Context::ContextBuilder::with_progress_callback(ProgressCallbackFunc)` Attaches a progress callback to the context being built. Chainable with with_settings(), with_json(), and with_signer(). The heap-allocated std::function is owned by the resulting Context and freed on destruction. - `Context::cancel() noexcept` Requests cancellation of the current in-progress operation. Safe to call from another thread. Implementation (c2pa_context.cpp): - `progress_callback_trampoline` — static C-compatible trampoline that forwards (user_data, phase, step, total) to the stored std::function. - `ContextBuilder::pending_callback_` — unique_ptr holding the heap-allocated callback between with_progress_callback() and create_context(). - `Context::callback_owner_` — void* that takes ownership of the raw pointer on create_context(); deleted in ~Context() and forwarded by move ops. Tests (context.test.cpp): - ProgressCallback_InvokedDuringSigning / _InvokedDuringReading - ProgressCallback_StepAndTotalValues - ProgressCallback_ReturnFalseCancels - ProgressCallback_CancelMethodAbortsOperation - CancelWithoutCallback_IsNoOp - ProgressCallback_ChainWithSettings - ProgressCallback_SurvivesContextMove / _SurvivesBuilderMove Requires: c2pa-rs >= 0.79.0 built from source (C2PA_BUILD_FROM_SOURCE=ON) pointing to a c2pa-rs checkout containing the progress/cancel feature. Made-with: Cursor
Bump c2pa-rs dependency from pre-release 0.78.4 to published 0.78.7; bump project to 0.18.3 Replace C2paProgressPhase (C unscoped enum) with c2pa::ProgressPhase scoped enum class in the public API; add static_asserts to catch any future C/C++ enum divergence at compile time Fix trampoline signature to match published ABI (const void*, int return, enum-typed phase) Update tests and remove stale @note Requires c2pa-rs >= 0.79.0 comments Add progress/cancel section to context-settings.md
tmathern
reviewed
Mar 28, 2026
tmathern
approved these changes
Mar 28, 2026
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.
Update progress/cancel API to published c2pa-rs 0.78.7
Bump c2pa-rs dependency from pre-release 0.78.4 to published 0.78.7; bump project to 0.18.3
Replace C2paProgressPhase (C unscoped enum) with c2pa::ProgressPhase scoped enum class in the public API; add static_asserts to catch any future C/C++ enum divergence at compile time
Fix trampoline signature to match published ABI (const void*, int return, enum-typed phase)
Update tests and remove stale @note Requires c2pa-rs >= 0.79.0 comments
Add progress/cancel section to context-settings.md