Skip to main content

reallyme_codec/
lib.rs

1// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
2//
3// SPDX-License-Identifier: Apache-2.0
4
5//! # reallyme-codec
6//!
7//! Codec-only utilities used by ReallyMe and DID tooling: base encodings,
8//! canonical JSON/CBOR serialization, multicodec lookup, and multikey handling.
9//! This crate deliberately has no cryptographic primitive dependencies.
10
11#![forbid(unsafe_code)]
12
13/// Standard (RFC 4648) base64 encode/decode.
14#[cfg(feature = "base64")]
15pub mod base64 {
16    pub use codec_base64::{base64_to_bytes, bytes_to_base64, Base64Error};
17}
18
19/// URL-safe (RFC 4648 §5) base64 encode/decode without padding.
20#[cfg(feature = "base64url")]
21pub mod base64url {
22    pub use codec_base64url::{
23        base64url_bytes_to_bytes, base64url_to_bytes, bytes_to_base64url, Base64UrlError,
24    };
25}
26
27/// DAG-CBOR encode/decode and content-identifier helpers.
28#[cfg(feature = "cbor")]
29pub mod cbor {
30    pub use codec_cbor::{
31        compute_cid_dag_cbor, dag_cbor_multihash, decode_dag_cbor, encode_dag_cbor,
32        is_valid_cid_string, sha2_256_content_hash, try_parse_cid, verify_dag_cbor_cid, CborError,
33        CborValue, ContentHash, DagCborMultihash, DAG_CBOR_CODEC,
34    };
35}
36
37/// JSON Canonicalization Scheme (RFC 8785) serialization.
38#[cfg(feature = "jcs")]
39pub mod jcs {
40    pub use codec_jcs::{canonicalize_json, JcsError};
41}
42
43/// Multibase self-describing base encodings.
44#[cfg(feature = "multibase")]
45pub mod multibase {
46    pub use codec_multibase::{
47        base58btc_decode, base58btc_encode, bytes_to_multibase58btc, bytes_to_multibase_base64url,
48        multibase_to_bytes, Base58Error, MultibaseError,
49    };
50}
51
52/// Multicodec varint prefix lookup and stripping.
53#[cfg(feature = "multicodec")]
54pub mod multicodec {
55    pub use codec_multicodec::{
56        lookup_codec_prefix, strip_codec_prefix, CodecLookupResult, CodecSpec, MULTICODEC_TABLE,
57    };
58}
59
60/// Multikey encoding/parsing that binds an algorithm to opaque key bytes.
61#[cfg(feature = "multikey")]
62pub mod multikey {
63    pub use codec_multikey::{
64        binding_type_matches_codec, encode_multikey, parse_multikey, validate_key_binding,
65        KeyBindingInput, MultikeyError, ParsedMultikey,
66    };
67}