structfs_core_store/lib.rs
1//! Core StructFS: Semantic Store Layer
2//!
3//! This layer adds meaning to the raw bytes of LLStructFS:
4//! - `Path`: Validated path with Unicode identifier components
5//! - `Value`: Parsed tree structure (the "struct" in StructFS)
6//! - `Record`: Either raw bytes or parsed Value
7//! - `Format`: Hint about wire format for codecs
8//!
9//! Use this layer for:
10//! - Application routing based on validated paths
11//! - Format-aware caching and transformation
12//! - Working with structured data
13//!
14//! # Example
15//!
16//! ```rust
17//! use structfs_core_store::{Reader, Writer, Record, Path, path};
18//!
19//! fn read_user(store: &mut dyn Reader) -> Result<Option<Record>, structfs_core_store::Error> {
20//! store.read(&path!("users/123"))
21//! }
22//! ```
23
24// Allow code generated by the re-exported `path!` proc macro (which emits
25// `::structfs_core_store::...` paths) to compile inside this crate too.
26extern crate self as structfs_core_store;
27
28pub use bytes::Bytes;
29
30mod bridge;
31mod combinators;
32pub mod conformance;
33mod error;
34mod format;
35mod lazy_record;
36mod memory_store;
37pub mod mount_store;
38pub mod overlay_store;
39mod path;
40mod path_pattern;
41pub mod path_trie;
42mod record;
43mod reference;
44mod serde_impls;
45mod traits;
46mod value;
47
48pub use bridge::{CoreToLL, LLToCore};
49pub use combinators::{Cascade, Masked, ReadOnly, Rooted, Shared};
50pub use error::{CodecErrorKind, CodecOperation, Error};
51pub use format::Format;
52pub use lazy_record::LazyRecord;
53pub use memory_store::MemoryStore;
54pub use path::{Path, PathComponent, PathError};
55pub use path_pattern::PathPattern;
56pub use path_trie::PathTrie;
57pub use record::Record;
58pub use reference::{Reference, TypeDescriptor, TypeInfo};
59pub use traits::{Codec, NoCodec, Reader, Store, Writer};
60pub use value::Value;
61
62/// Compile-time validated path construction.
63///
64/// String literals are validated against the path grammar at compile time;
65/// runtime expressions must be [`PathComponent`] values.
66///
67/// ```rust
68/// use structfs_core_store::{path, PathComponent};
69///
70/// let p = path!("users/123/name");
71/// assert_eq!(p.len(), 3);
72///
73/// let name = PathComponent::try_new("alice").unwrap();
74/// let p = path!("users", name, "profile");
75/// assert_eq!(p.to_string(), "users/alice/profile");
76/// ```
77pub use structfs_path_macro::path;
78
79// Re-export LL types for convenience
80pub use structfs_ll_store::{LLError, LLPath, LLReader, LLStore, LLWriter};
81
82// Async support
83#[cfg(feature = "async")]
84mod async_traits;
85
86#[cfg(feature = "async")]
87mod async_bridge;
88
89#[cfg(feature = "async")]
90pub use async_traits::{
91 AsyncReader, AsyncStore, AsyncWriter, DetachedFuture, DetachedReader, DetachedStore,
92 DetachedWriter, SyncToAsync,
93};
94
95#[cfg(feature = "async")]
96pub use async_bridge::{AsyncCoreToLL, AsyncLLToCore};
97
98// Re-export async LL types when async feature is enabled
99#[cfg(feature = "async")]
100pub use structfs_ll_store::{AsyncLLReader, AsyncLLStore, AsyncLLWriter, SyncToAsyncLL};