protocache-core 0.1.1

Core zero-copy runtime and encoding primitives for ProtoCache
Documentation
//! Protobuf-free runtime for reading and writing the ProtoCache wire format.
//!
//! Encoded documents are represented as little-endian `u32` words. Read-only
//! views borrow those words and do not allocate; mutable wrappers decode fields
//! lazily and can preserve untouched encoded data when serializing again.
//!
//! Most applications start with [`runtime::MessageView`]. Code generated by
//! `protoc-gen-pcrs` builds typed accessors on the same runtime. Use
//! [`mutable`] for document updates and [`encoding`] for schema-independent,
//! low-level construction.
//!
//! Constructors return `None` when the supplied words do not contain a valid
//! value of the requested shape. Callers that accept untrusted data should use
//! those checked constructors instead of the `expect_*` convenience methods.

/// Zero-copy views over encoded strings, messages, arrays, and maps.
pub mod access;
/// Mutable containers and traits used by generated mutable bindings.
pub mod mutable;
/// Reader and builder support for ProtoCache perfect-hash indexes.
pub mod perfect_hash;
/// Low-level encoding primitives for schema-independent writers.
pub mod serialize;
/// Shared scalar, buffer, compression, and error utilities.
pub mod utils;

mod hash;

/// Common zero-copy read APIs re-exported for Rust-first integrations.
pub mod runtime {
    pub use crate::access::*;
}

/// Common low-level write APIs re-exported for Rust-first integrations.
pub mod encoding {
    pub use crate::serialize::*;
    pub use crate::utils::{Buffer, Bytes, EnumValue, Scalar, Words};
}

pub use access::{
    ArrayIter, ArrayView, BoolArray, FieldDecode, FieldView, MapIter, MapKey, MapView, MessageView,
    PairView, ScalarArray, StringView, ViewArray, ViewMap, detect_array_with, detect_map_with,
    detect_slice_end,
};
pub use mutable::{
    MutableArray, MutableArrayElement, MutableError, MutableField, MutableMap, MutableMapKey,
    MutableMapKeyKind, MutableMessage, copy_words,
};
pub use perfect_hash::PerfectHashView;
pub use serialize::{
    Segment, Unit, build_perfect_hash_index, build_perfect_hash_index_with_positions, fold_field,
    serialize_array, serialize_array_at, serialize_array_at_mut, serialize_bool, serialize_bytes,
    serialize_map, serialize_map_at, serialize_map_at_mut, serialize_message, serialize_message_at,
    serialize_scalar, serialize_str,
};
pub use utils::{
    Buffer, Bytes, CorruptionKind, EnumValue, ReadError, Scalar, Words, compress, compress_into,
    decompress, decompress_into,
};

#[cfg(test)]
mod tests;