Skip to main content

Crate c2pa_c

Crate c2pa_c 

Source

Modules§

cimpl_error
macros
FFI Helper Macros
utils
FFI Utilities

Macros§

arc_tracked
Create an Arc-wrapped pointer and track it Returns the raw pointer
box_tracked
Create a Box-wrapped pointer and track it Returns the raw pointer
bytes_or_return
Validate and convert raw C byte array to safe slice, returning early on error.
bytes_or_return_int
Validate and convert raw C byte array to safe slice, return -1 on error.
bytes_or_return_null
Validate and convert raw C byte array to safe slice, return NULL on error.
cimpl_free
Free a pointer that was allocated by cimpl.
cstr_option
Convert a *const c_char to Option<String>. Returns None if the pointer is null. Returns Some(String) if the pointer is not null. Returns None if the string is too long.
cstr_or_return
Convert C string with bounded length check or early-return with error value. Errors if the string exceeds MAX_CSTRING_LEN bytes.
cstr_or_return_int
cstr_or_return_null
If the expression is null, set the last error and return std::ptr::null_mut().
cstr_or_return_with_limit
Convert C string with custom length limit or early-return with error value. Errors if the string exceeds max_len bytes.
deref_mut_or_return
Validate pointer and dereference mutably, returning reference Returns early with custom value on error
deref_mut_or_return_int
Validate pointer and dereference mutably, returning reference Returns -1 on error
deref_mut_or_return_null
Validate pointer and dereference mutably, returning reference Returns NULL on error
deref_or_return_false
Validate pointer and dereference immutably, returning reference Returns false on error
deref_or_return_int
Validate pointer and dereference immutably, returning reference Returns -1 on error
deref_or_return_null
Validate pointer and dereference immutably, returning reference Returns NULL on error
deref_or_return_zero
Validate pointer and dereference immutably, returning reference Returns 0 on error
ok_or_return
Handle Result or early-return with error value
ok_or_return_false
Handle Result, early-return with false on error
ok_or_return_int
Handle Result, early-return with -1 (negative) on error
ok_or_return_null
Handle Result, early-return with null on error
ok_or_return_zero
Handle Result, early-return with 0 on error
option_to_c_string
Converts an Option<String> to a C string pointer. Returns null_mut() if the Option is None.
ptr_or_return
Check pointer not null or early-return with error value
ptr_or_return_int
If the expression is null, set the last error and return -1.
ptr_or_return_null
If the expression is null, set the last error and return null.
some_or_return
Handle Option, early-return with custom value if None
some_or_return_false
Handle Option, early-return with false if None
some_or_return_int
Handle Option, early-return with -1 if None
some_or_return_null
Handle Option, early-return with NULL if None
some_or_return_zero
Handle Option, early-return with 0 if None
untrack_or_return
Untrack a pointer from the registry (ownership transfer from C to Rust).
untrack_or_return_int
Untrack a pointer from the registry, returning -1 on error.
untrack_or_return_null
Untrack a pointer from the registry, returning NULL on error.

Structs§

Builder
Use a Builder to add a signed manifest to an asset.
C2paHttpRequest
HTTP request passed to the resolver callback.
C2paHttpResolver
Opaque handle for a C-callback-based HTTP resolver. Created by c2pa_http_resolver_create(). Either consumed by c2pa_context_builder_set_http_resolver() or freed via c2pa_free().
C2paHttpResponse
HTTP response filled in by the resolver callback.
C2paSigner
C2paSignerInfo
Defines the configuration for a Signer.
C2paStream
A C2paStream is a Rust Read/Write/Seek stream that can be created and used in C.
Reader
Use a Reader to read and validate a manifest store.
SignerInfo
SignerInfo provides the information needed to create a signer and sign a manifest.
StreamContext
An opaque struct to hold a context value for the stream callbacks.
TestC2paStream
This struct is used to test the C2paStream implementation.

Enums§

C2paBuilderIntent
Builder intent enumeration. This specifies what kind of manifest to create.
C2paDigitalSourceType
List of possible digital source types.
C2paError
Error enumerates errors returned by most C2PA toolkit operations.
C2paHashType
Hash binding type for embeddable signing workflows.
C2paProgressPhase
Progress phase constants passed to C progress callbacks. These mirror c2pa::ProgressPhase variants.
C2paSeekMode
Defines the seek mode for the seek callback.
C2paSigningAlg
List of supported signing algorithms.
SigningAlg
Describes the digital signature algorithms allowed by the C2PA spec.

Traits§

AsyncSigner
The AsyncSigner trait generates a cryptographic signature over a byte array.
Signer
The Signer trait generates a cryptographic signature over a byte array.

Functions§

c2pa_builder_add_action
Adds an action to the manifest the Builder is constructing.
c2pa_builder_add_ingredient_from_archive
Adds an ingredient to the C2paBuilder from a C2PA ingredient archive stream.
c2pa_builder_add_ingredient_from_stream
Adds an ingredient to the C2paBuilder.
c2pa_builder_add_resource
Adds a resource to the C2paBuilder.
c2pa_builder_data_hashed_placeholder
Creates a hashed placeholder from a Builder. The placeholder is used to reserve size in an asset for later signing.
c2pa_builder_freeDeprecated
Frees a C2paBuilder allocated by Rust.
c2pa_builder_from_archiveDeprecated
Create a C2paBuilder from an archive stream.
c2pa_builder_from_context
Creates a C2paBuilder from a shared Context.
c2pa_builder_from_jsonDeprecated
Creates a C2paBuilder from a JSON manifest definition string.
c2pa_builder_hash_mdat_bytes
Generate the mdat leaf hashes for the asset, the C2paHasher will accumulate the hash values for each mdat_id. The data_ptr should be supplied in the order the chunks are written to the mdat. The mdat_id should be begin with 0 and increment for each mdat in the asset. For assets with a s ingle mdat, the mdat_id should be 0. If fixed size Merkle is enabled, the data will be accumulated and hashed in fixed size chunks and the final chunk will be padded. Otherwise the data will be hashed as a single leaf for each mdat chunk supplied to this call.
c2pa_builder_hash_type
Returns the hash binding type that the builder will use for the given format.
c2pa_builder_needs_placeholder
Returns whether a placeholder manifest is required for the given format.
c2pa_builder_placeholder
Creates a composed placeholder manifest from a Builder.
c2pa_builder_set_base_path
⚠️ Deprecated Soon This method is planned to be deprecated in a future release. Usage should be limited and temporary.
c2pa_builder_set_data_hash_exclusions
Sets the byte exclusion ranges on the DataHash assertion in a Builder.
c2pa_builder_set_fixed_size_merkle
If set the hasher will hash fixed size chunks of data, padding the final block as needed. This will produce a Merkle tree for each mdat with fixed size leaves, which can be used for efficient hashing of large assets.
c2pa_builder_set_intent
Sets the builder intent on the Builder.
c2pa_builder_set_no_embed
Sets the no-embed flag on the Builder. When set, the builder will not embed a C2PA manifest store into the asset when signing. This is useful when creating cloud or sidecar manifests.
c2pa_builder_set_remote_url
Sets the remote URL on the Builder. When set, the builder will embed a remote URL into the asset when signing. This is useful when creating cloud based Manifests.
c2pa_builder_sign
Creates and writes signed manifest from the C2paBuilder to the destination stream.
c2pa_builder_sign_context
Sign using the Signer from the Context.
c2pa_builder_sign_data_hashed_embeddable
Sign a Builder using the specified signer and data hash. The data hash is a JSON string containing DataHash information for the asset. This is a low-level method for advanced use cases where the caller handles embedding the manifest.
c2pa_builder_sign_embeddable
Signs the manifest and returns composed bytes ready for embedding.
c2pa_builder_supported_mime_types
Returns an array of char* pointers to the supported mime types. The caller is responsible for freeing the array.
c2pa_builder_to_archive
Writes an Archive of the Builder to the destination stream.
c2pa_builder_update_hash_from_stream
Updates the hard binding assertion in a Builder by hashing an asset stream.
c2pa_builder_with_archive
Configures an existing builder with an archive stream.
c2pa_builder_with_definition
Updates the builder with a new manifest definition.
c2pa_builder_write_ingredient_archive
Writes a single-ingredient C2PA archive to the destination stream.
c2pa_context_builder_build
Builds an immutable, shareable context from the builder.
c2pa_context_builder_new
Creates a new context builder with default settings.
c2pa_context_builder_set_http_resolver
Sets a custom HTTP resolver on the context builder.
c2pa_context_builder_set_progress_callback
Attaches a C progress callback to a context builder.
c2pa_context_builder_set_settings
Updates the builder with settings.
c2pa_context_builder_set_signer
Set a Signer into the Builder’s context. (The context will own the Signer from that point on). The signer will be available via context.signer() after building the context. If a signer is also configured in settings, the programmatic signer takes priority regardless of call order.
c2pa_context_cancel
Requests cancellation of any in-progress operation on this context.
c2pa_context_new
Creates a new immutable context with default settings.
c2pa_create_stream
Creates a new C2paStream from context with callbacks.
c2pa_ed25519_sign
Signs a byte array using the Ed25519 algorithm.
c2pa_error
Returns the last error message.
c2pa_error_set_last
Sets the last error message. This is used by callbacks so they can set a return error message. THe error should be in the form of “ErrorType: ErrorMessage”. If ErrorType is missing or invalid, it will be set to “Other”. and the message will include the original error string. Can return -1 if the error string is NULL.
c2pa_format_embeddable
Convert a binary c2pa manifest into an embeddable version for the given format. A raw manifest (in application/c2pa format) can be uploaded to the cloud but it cannot be embedded directly into an asset without extra processing. This method converts the raw manifest into an embeddable version that can be embedded into an asset.
c2pa_free
Frees any pointer allocated by this library.
c2pa_free_string_array
Frees an array of char* pointers created by Rust.
c2pa_http_resolver_create
Creates a new HTTP resolver backed by a C callback.
c2pa_load_settingsDeprecated
Load Settings from a string. Sets thread-local settings.
c2pa_manifest_bytes_freeDeprecated
Frees a C2PA manifest returned by c2pa_builder_sign.
c2pa_reader_detailed_json
Returns a detailed JSON string generated from a C2paReader.
c2pa_reader_freeDeprecated
Frees a C2paReader allocated by Rust.
c2pa_reader_from_context
Creates a new C2paReader from a shared context.
c2pa_reader_from_manifest_data_and_streamDeprecated
Creates and verifies a C2paReader from an asset stream with the given format and manifest data.
c2pa_reader_from_streamDeprecated
Example
c2pa_reader_is_embedded
Returns if the reader was created from an embedded manifest.
c2pa_reader_json
Returns a JSON string generated from a C2paReader.
c2pa_reader_new
Creates a new C2paReader from a default context.
c2pa_reader_remote_url
Returns the remote url of the manifest if it was obtained remotely.
c2pa_reader_resource_to_stream
Writes a C2paReader resource to a stream given a URI.
c2pa_reader_supported_mime_types
Returns an array of char* pointers to c2pa::Reader’s supported mime types. The caller is responsible for freeing the array.
c2pa_reader_with_fragment
Configures an existing reader with a fragment stream.
c2pa_reader_with_manifest_data_and_stream
Configures an existing passed in Reader with manifest data and a stream. This covers the case when a Reader needs to be able to re-read signed manifest bytes. This method consumes the original Reader and returns a new configured Reader. The original Reader pointer becomes invalid after this call and should not be reused.
c2pa_reader_with_stream
Configures an existing reader with a stream.
c2pa_release_stream
Releases a C2paStream allocated by Rust.
c2pa_release_stringDeprecated
Frees a string allocated by Rust.
c2pa_settings_new
Creates a new C2PA settings object with default values.
c2pa_settings_set_value
Sets a specific configuration value in the settings using dot notation.
c2pa_settings_update_from_string
Updates settings from a JSON or TOML string.
c2pa_signature_freeDeprecated
Frees a signature allocated by Rust.
c2pa_signer_create
Creates a C2paSigner from a callback and configuration.
c2pa_signer_freeDeprecated
Frees a C2paSigner allocated by Rust.
c2pa_signer_from_info
Creates a C2paSigner from a SignerInfo. The signer is created from the sign_cert and private_key fields. an optional url to an RFC 3161 compliant time server will ensure the signature is timestamped.
c2pa_signer_from_settingsDeprecated
Creates a C2paSigner from the settings. The signer is created from the settings defined in the c2pa_settings.json file.
c2pa_signer_reserve_size
Returns the size to reserve for the signature for this signer.
c2pa_string_freeDeprecated
Frees a string allocated by Rust.
c2pa_version
Returns a version string for logging.
cimpl_free
Universal free function for any tracked pointer
safe_slice_from_raw_parts
Creates a safe slice from raw parts with bounds validation
to_c_bytes
Converts a Vec <u8> to a tracked C byte array pointer
to_c_string
Converts a Rust String to a C string (*mut c_char)
track_arc
Track an Arc-wrapped pointer
track_arc_mutex
Track an Arc<Mutex<T>>-wrapped pointer
track_box
Track a Box-wrapped pointer
untrack_pointer
Remove a pointer from tracking without running its cleanup function.
validate_pointer
Validate that a pointer is tracked and has the expected type

Type Aliases§

C2paHttpResolverCallback
Callback type for custom HTTP request resolution.
C2paResult
A specialized Result type for C2PA toolkit operations.
Error
ProgressCCallback
C-callable progress callback function type.
Result
SignerCallback
Defines a callback to read from a stream.