Skip to content

Commit fe49a29

Browse files
ok-nickcrandmck
andauthored
docs: document features in Rust docs and clarify features (#1491)
* docs: document features in lib.rs and clarify features * fix: remove `serialize_thumbnails` feature docs * docs: clarify feature language * docs: clarify removed serialize_thumbnails feature * Copy edits * docs: move back feature docs before merge overwrite * docs: clarify language --------- Co-authored-by: Rand McKinney <[email protected]>
1 parent 3c3fed5 commit fe49a29

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

docs/usage.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,26 @@ c2pa = { version = "0.45.2", features = ["file_io", "add_thumbnails"] }
3232

3333
## Features
3434

35-
The Rust library crate provides the following capabilities:
35+
You can enable any of the following features:
3636

37-
* `openssl` *(enabled by default)* - Enables the system `openssl` implementation for cryptography.
38-
* `rust_native_crypto` - Enables the Rust native implementation for cryptography.
39-
* `add_thumbnails` generates thumbnails automatically for JPEG and PNG files. (no longer included with `file_io`)
40-
* `fetch_remote_manifests` enables the verification step to retrieve externally referenced manifest stores. External manifests are only fetched if there is no embedded manifest store and no locally adjacent .c2pa manifest store file of the same name.
41-
* `file_io` enables manifest generation, signing via OpenSSL, and embedding manifests in [supported file formats](supported-formats.md).
42-
* `json_schema` is used by `make schema` to produce a JSON schema document that represents the `ManifestStore` data structures.
43-
* `pdf` - Enable support for reading claims on PDF files.
37+
- **openssl** *(enabled by default)*: Use the vendored `openssl` implementation for cryptography.
38+
- **rust_native_crypto**: Use Rust native cryptography.
39+
- **add_thumbnails**: Adds the [`image`](https://github.com/image-rs/image) crate to enable auto-generated thumbnails, if possible and enabled in settings.
40+
- **fetch_remote_manifests**: Fetches remote manifests over the network when no embedded manifest is present and that option is enabled in settings.
41+
- **file_io**: Enables APIs that use filesystem I/O.
42+
- **json_schema**: Adds the [`schemars`](https://github.com/GREsau/schemars) crate to derive JSON schemas for JSON-compatible structs.
43+
- **pdf**: Enables basic PDF read support.
4444

45-
* the `v1_api` feature is no longer supported.
45+
> [!NOTE]
46+
> If both `rust_native_crypto` and `openssl` are enabled, then only `rust_native_crypto` will be enabled.
47+
> To avoid including `openssl` as a dependency, disable default features when using `rust_native_crypto`.
4648
47-
[!NOTE]
48-
If both `rust_native_crypto` and `openssl` are enabled, it will default to `rust_native_crypto`.
49-
It is recommended to disable default features when using `rust_native_crypto` as to avoid including `openssl` as a dependency.
49+
### Features no longer supported
5050

51+
The following features are no longer supported:
52+
53+
* **v1_api**. The old API that this enabled has been removed.
54+
* **serialize_thumbnails**. Thumbnails can be serialized by accessing resources directly.
5155

5256
### Resource references
5357

@@ -60,19 +64,20 @@ When defining a resource for the [ManifestStoreBuilder](https://docs.rs/c2pa/lat
6064
The specification often requires adding a `HashedUri` to an assertion. Since the JUMBF URIs for a new manifest are not known when defining the manifest, this creates a "chicken and egg" scenario, resolved with local resource references. When constructing the JUMBF for a manifest, the library converts all local URI references into JUMBF references and corrects the the associated cross references.
6165

6266
URI schemes in a resource reference can have the following forms:
67+
6368
- `self#jumbf` - An internal JUMBF reference
6469
- `file:///` - A local file reference
6570
- `app://contentauth/` - A working store reference
6671
- `http://` - Remote URI
6772
- `https://` - Remote secure URI
6873

69-
Note that the `file:` and `app:` schemes are only used in the context of ManifestStoreBuilder and will never be in JUMBF data. This is proposal, currently there is no implementation for file or app schemes and we do not yet handle http/https schemes this way.
74+
Note that the `file:` and `app:` schemes are only used in the context of `ManifestStoreBuilder` and will never be in JUMBF data. This is proposal, currently there is no implementation for file or app schemes and we do not yet handle HTTP/HTTPS schemes this way.
7075

7176
<!-- Is the above still true? "This is proposal, currently there is no implementation" -->
7277

7378
When `file_io` is enabled, the lack of a scheme will be interpreted as a `file:///` reference, otherwise as an `app:` reference.
7479

75-
### Source asset vs parent asset
80+
### Source asset versus parent asset
7681

7782
The source asset isn't always the parent asset: The source asset is the asset that is hashed and signed. It can be the output from an editing application that has not preserved the manifest store from the parent. In that case, the application should have extracted a parent ingredient from the parent asset and added that to the manifest definition.
7883

@@ -86,6 +91,7 @@ If there is no parent ingredient defined, and the source has a manifest store, t
8691
### Remote URLs and embedding
8792

8893
The default operation of C2PA signing is to embed a C2PA manifest store into an asset. The library also returns the C2PA manifest store so that it can be written to a sidecar or uploaded to a remote service.
94+
8995
- The API supports embedding a remote URL reference into the asset.
9096
- The remote URL is stored in different ways depending on the asset, but is often stored in XMP data.
9197
- The remote URL must be added to the asset before signing so that it can be hashed along with the asset.
@@ -95,7 +101,6 @@ The default operation of C2PA signing is to embed a C2PA manifest store into an
95101
- The remote URL can be set with `builder.remote_url`.
96102
- If embedding is not needed, set the `builder.no_embed` flag to `true`.
97103

98-
99104
## Example code
100105

101106
The [sdk/examples](https://github.com/contentauth/c2pa-rs/tree/main/sdk/examples) directory contains some minimal example code. The [client/client.rs](https://github.com/contentauth/c2pa-rs/blob/main/sdk/examples/client/client.rs) is the most instructive and provides and example of reading the contents of a manifest store, recursively displaying nested manifests.

sdk/src/lib.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
//! The library has a Builder/Reader API that focuses on simplicity
2626
//! and stream support.
2727
//!
28-
//! ## Example: Reading a ManifestStore
28+
//! # Examples
29+
//!
30+
//! ## Reading a manifest
2931
//!
3032
//! ```
3133
//! # use c2pa::Result;
@@ -46,7 +48,7 @@
4648
//! # }
4749
//! ```
4850
//!
49-
//! ## Example: Adding a Manifest to a file
51+
//! ## Adding a manifest to a file
5052
//!
5153
//! ```ignore-wasm32
5254
//! # use c2pa::Result;
@@ -86,6 +88,18 @@
8688
//! # Ok(())
8789
//! # }
8890
//! ```
91+
//!
92+
//! # Features
93+
//!
94+
//! You can enable any of the following features:
95+
//!
96+
//! - **openssl** *(enabled by default)*: Use the vendored `openssl` implementation for cryptography.
97+
//! - **rust_native_crypto**: Use Rust native cryptography.
98+
//! - **add_thumbnails**: Adds the [`image`](https://github.com/image-rs/image) crate to enable auto-generated thumbnails, if possible and enabled in settings.
99+
//! - **fetch_remote_manifests**: Fetches remote manifests over the network when no embedded manifest is present and that option is enabled in settings.
100+
//! - **file_io**: Enables APIs that use filesystem I/O.
101+
//! - **json_schema**: Adds the [`schemars`](https://github.com/GREsau/schemars) crate to derive JSON schemas for JSON-compatible structs.
102+
//! - **pdf**: Enables basic PDF read support.
89103
90104
/// The internal name of the C2PA SDK
91105
pub const NAME: &str = "c2pa-rs";

0 commit comments

Comments
 (0)