protocache_core/lib.rs
1//! Protobuf-free runtime for reading and writing the ProtoCache wire format.
2//!
3//! Encoded documents are represented as little-endian `u32` words. Read-only
4//! views borrow those words and do not allocate; mutable wrappers decode fields
5//! lazily and can preserve untouched encoded data when serializing again.
6//!
7//! Most applications start with [`runtime::MessageView`]. Code generated by
8//! `protoc-gen-pcrs` builds typed accessors on the same runtime. Use
9//! [`mutable`] for document updates and [`encoding`] for schema-independent,
10//! low-level construction.
11//!
12//! Constructors return `None` when the supplied words do not contain a valid
13//! value of the requested shape. Callers that accept untrusted data should use
14//! those checked constructors instead of the `expect_*` convenience methods.
15
16/// Zero-copy views over encoded strings, messages, arrays, and maps.
17pub mod access;
18/// Mutable containers and traits used by generated mutable bindings.
19pub mod mutable;
20/// Reader and builder support for ProtoCache perfect-hash indexes.
21pub mod perfect_hash;
22/// Low-level encoding primitives for schema-independent writers.
23pub mod serialize;
24/// Shared scalar, buffer, compression, and error utilities.
25pub mod utils;
26
27mod hash;
28
29/// Common zero-copy read APIs re-exported for Rust-first integrations.
30pub mod runtime {
31 pub use crate::access::*;
32}
33
34/// Common low-level write APIs re-exported for Rust-first integrations.
35pub mod encoding {
36 pub use crate::serialize::*;
37 pub use crate::utils::{Buffer, Bytes, EnumValue, Scalar, Words};
38}
39
40pub use access::{
41 ArrayIter, ArrayView, BoolArray, FieldDecode, FieldView, MapIter, MapKey, MapView, MessageView,
42 PairView, ScalarArray, StringView, ViewArray, ViewMap, detect_array_with, detect_map_with,
43 detect_slice_end,
44};
45pub use mutable::{
46 MutableArray, MutableArrayElement, MutableError, MutableField, MutableMap, MutableMapKey,
47 MutableMapKeyKind, MutableMessage, copy_words,
48};
49pub use perfect_hash::PerfectHashView;
50pub use serialize::{
51 Segment, Unit, build_perfect_hash_index, build_perfect_hash_index_with_positions, fold_field,
52 serialize_array, serialize_array_at, serialize_array_at_mut, serialize_bool, serialize_bytes,
53 serialize_map, serialize_map_at, serialize_map_at_mut, serialize_message, serialize_message_at,
54 serialize_scalar, serialize_str,
55};
56pub use utils::{
57 Buffer, Bytes, CorruptionKind, EnumValue, ReadError, Scalar, Words, compress, compress_into,
58 decompress, decompress_into,
59};
60
61#[cfg(test)]
62mod tests;