Skip to main content

Crate cjc_snap

Crate cjc_snap 

Source
Expand description

Content-addressable serialization for CJC values.

cjc-snap provides deterministic binary encoding of Value types with SHA-256 content hashing. Zero external dependencies – the SHA-256 implementation is hand-rolled following FIPS 180-4.

§Overview

  Value ──snap_encode──> bytes ──sha256──> hash
         ◄──snap_decode──

The high-level API is snap() / restore():

let blob = cjc_snap::snap(&value);
let restored = cjc_snap::restore(&blob).unwrap();

Re-exports§

pub use hash::sha256;
pub use encode::snap_encode;
pub use encode::snap_encode_v2;
pub use encode::encode_typed_tensor;
pub use encode::encode_chunked_tensor;
pub use encode::encode_sparse_csr;
pub use encode::encode_categorical;
pub use encode::encode_schema;
pub use encode::encode_dataframe;
pub use encode::DataFrameColumnData;
pub use encode::DEFAULT_CHUNK_SIZE;
pub use encode::TAG_TYPED_TENSOR;
pub use encode::TAG_CHUNKED_TENSOR;
pub use encode::TAG_SPARSE_CSR;
pub use encode::TAG_CATEGORICAL;
pub use encode::TAG_SCHEMA;
pub use encode::TAG_DATAFRAME;
pub use encode::SNAP_MAGIC;
pub use encode::SNAP_VERSION;
pub use encode::COL_TYPE_INT;
pub use encode::COL_TYPE_FLOAT;
pub use encode::COL_TYPE_STR;
pub use encode::COL_TYPE_BOOL;
pub use encode::COL_TYPE_CATEGORICAL;
pub use encode::COL_TYPE_DATETIME;
pub use decode::snap_decode;
pub use decode::snap_decode_v2;
pub use json::snap_to_json;
pub use persist::snap_save;
pub use persist::snap_save_v2;
pub use persist::snap_load;

Modules§

decode
Decoding of canonically-encoded CJC values.
encode
Canonical binary encoding for CJC Value types.
hash
Hand-rolled SHA-256 implementation following FIPS 180-4.
json
Value-to-JSON converter for cross-language interop.
persist
File persistence for CJC Snap — save/load values to disk.

Structs§

SnapBlob
A content-addressable blob: the canonical binary encoding of a Value together with its SHA-256 digest.

Enums§

SnapError
Errors that can occur during snap decoding or integrity verification.

Functions§

is_snappable
Check whether a Value can be snap-encoded without panicking.
restore
Restore a Value from a SnapBlob, verifying data integrity.
restore_v2
Restore a Value from a SnapBlob, auto-detecting v1 or v2 format.
snap
Encode a Value into a content-addressable SnapBlob (v1 format).
snap_v2
Encode a Value into a content-addressable SnapBlob (v2 format with header).