uor-addr-c 0.2.0

C ABI bindings for uor-addr — typed content-addressing exposed over `extern "C"` for embedded and any-language consumption.
Documentation

uor-addr-c

C ABI bindings for uor-addr — typed content-addressing exposed over extern "C" so embedded toolchains and any language with a C FFI can mint the same 71-byte sha256:<64hex> κ-label that the Rust crate produces, byte-for-byte.

What this crate is

A thin extern "C" marshalling layer over the uor-addr core. The core is no_std + no_alloc; this crate inherits that posture. The staticlib / cdylib outputs:

  • target/<profile>/libuor_addr_c.a — for embedded toolchains
  • target/<profile>/libuor_addr_c.so (.dylib on macOS, .dll on Windows) — for hosted FFI consumers

Plus a generated C header at include/uor_addr.h (auto-generated by cbindgen in build.rs — do not edit by hand).

API shape

Every UOR-ADDR realization is exposed as one entry point:

int32_t uor_addr_<realization>(
    const uint8_t *input,
    size_t         input_len,
    uint8_t       *out_label,
    size_t         out_label_len,
    size_t        *out_written);

Return value is one of:

Constant Meaning
UOR_ADDR_OK (0) Success; out_label[..71] holds the ASCII sha256:<64hex> κ-label.
UOR_ADDR_ERR_NULL_POINTER (-1) input == NULL && input_len > 0, or out_label == NULL.
UOR_ADDR_ERR_BUFFER_TOO_SMALL (-2) out_label_len < 71.
UOR_ADDR_ERR_INVALID_INPUT (-3) Input failed the realization's host-boundary parser.
UOR_ADDR_ERR_TOO_LARGE (-4) Input exceeded a typed-input ceiling.
UOR_ADDR_ERR_PIPELINE (-5) Defensive substrate-level failure; unreachable on well-formed input.

Exported entry points:

Symbol Realization
uor_addr_json JSON (RFC 8259 + RFC 8785 JCS + UAX #15 NFC)
uor_addr_sexp S-expressions (Rivest 1997 canonical form)
uor_addr_xml XML (W3C XML-C14N 1.1 subset)
uor_addr_asn1 ASN.1 (ITU-T X.690 DER)
uor_addr_ring Ring elements (UOR-Framework Amendment 43 §2)
uor_addr_codemodule CCMAS canonical AST
uor_addr_schema_photo schema.org/Photograph
uor_addr_schema_document schema.org/Article (+ standard subtypes)
uor_addr_schema_codemodule_signed in-toto Statement v1

Byte identity

The κ-label produced by this binding is byte-for-byte identical to uor_addr::<realization>::address(input).address. Callers can cross-check against the pure-Rust path; the FFI is a thin marshalling layer on top of the same no_alloc pipeline.

Building

# Default (no_std + no_alloc, embedded-friendly):
cargo build -p uor-addr-c --release

# Hosted (links libc, std panic handler):
cargo build -p uor-addr-c --release --features std

The C header at include/uor_addr.h regenerates on every build via the build.rs cbindgen invocation.

Consuming from other languages

The C ABI is the substrate for any language with a C FFI:

Language Mechanism
C / C++ #include "uor_addr.h" + link libuor_addr_c.a
Python cffi or ctypes
Go cgo
Ruby FFI gem
.NET P/Invoke
Swift C interop in Swift package manifests
Java / Kotlin JNI shim around the C ABI

License

Apache-2.0 — same as uor-addr.