Skip to main content

mnem_core/codec/
mod.rs

1//! Canonical encoding and decoding of mnem objects.
2//!
3//! Two codecs are exposed:
4//!
5//! - [`dagcbor`] - the canonical storage format. Byte-exact deterministic
6//!   per SPEC ยง3. Every content hash in mnem is computed over DAG-CBOR
7//!   output.
8//! - [`dagjson`] - a debug / inspection format. Never hashed, never written
9//!   to the object store as canonical content. Useful for
10//!   `mnem cat-file --json` and error messages.
11//!
12//! The most common operation is [`dagcbor::hash_to_cid`] which encodes a
13//! value to canonical CBOR and computes its content-addressed [CID].
14//!
15//! [CID]: crate::id::Cid
16
17pub mod dagcbor;
18pub mod dagjson;
19pub mod json;
20
21pub use dagcbor::{extract_links, from_canonical_bytes, hash_to_cid, to_canonical_bytes};
22pub use dagjson::{from_json_bytes, to_json_bytes};
23pub use json::{IPLD_MAX_DEPTH, JsonIpldError, json_to_ipld};