c2pa-structured-text 0.1.1

C2PA manifest embedding for structured text formats using ASCII armour delimiters
Documentation
  • Coverage
  • 6.67%
    1 out of 15 items documented0 out of 0 items with examples
  • Size
  • Source code size: 12.49 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 411.13 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 38s Average build duration of successful builds.
  • all releases: 29s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • writerslogic/c2pa-structured-text
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dcondrey

Overview

Implements the Structured Text Embedding section of the C2PA Technical Specification, which defines how to associate a C2PA Manifest Store with source code, configuration files, markup, and other text formats that support comment syntax or front matter conventions.

The manifest block uses fixed ASCII armour-style delimiters modelled on RFC 4880:

-----BEGIN C2PA MANIFEST----- <reference> -----END C2PA MANIFEST-----

Quick Start

[dependencies]
c2pa-structured-text = "0.1"

Embed a manifest reference

use c2pa_structured_text::{embed_manifest, ManifestRef};

let text = "print('hello')\n";
let signed = embed_manifest(
    text,
    ManifestRef::Url("https://example.com/manifests/abc.c2pa"),
    "#",       // comment prefix
    None,      // no comment suffix
);
// Result:
// # -----BEGIN C2PA MANIFEST----- https://example.com/manifests/abc.c2pa -----END C2PA MANIFEST-----
// print('hello')

Extract a manifest reference

use c2pa_structured_text::extract_manifest;

let text = "# -----BEGIN C2PA MANIFEST----- https://example.com/m.c2pa -----END C2PA MANIFEST-----\nprint('hello')\n";
let result = extract_manifest(text).unwrap();
assert_eq!(result.reference, "https://example.com/m.c2pa");

Supported Formats

Any text format with a comment syntax or front matter convention:

Comment Style Formats Example
# Python, Ruby, Shell, YAML, TOML # -----BEGIN C2PA MANIFEST----- ... -----END C2PA MANIFEST-----
// JavaScript, TypeScript, Go, Rust, C++ // -----BEGIN C2PA MANIFEST----- ... -----END C2PA MANIFEST-----
-- SQL, Lua, Haskell -- -----BEGIN C2PA MANIFEST----- ... -----END C2PA MANIFEST-----
/* */ CSS, C, Java /* -----BEGIN C2PA MANIFEST----- ... -----END C2PA MANIFEST----- */
<!-- --> HTML, XML, Markdown <!-- -----BEGIN C2PA MANIFEST----- ... -----END C2PA MANIFEST----- -->
NOTE WebVTT NOTE -----BEGIN C2PA MANIFEST----- ... -----END C2PA MANIFEST-----
Front matter Markdown (YAML), TOML Multi-line form between front matter delimiters

Related Crates

Crate Description
c2pa-text-binding Soft binding and content fingerprinting for text assets
c2pa-text Unstructured text embedding via Unicode Variation Selectors
c2pa-rs Official C2PA SDK

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.

Built by WritersLogic