structfs-core-store 0.2.0

Core StructFS store traits - Record, Value, Path, Format
Documentation
//! Core StructFS: Semantic Store Layer
//!
//! This layer adds meaning to the raw bytes of LLStructFS:
//! - `Path`: Validated path with Unicode identifier components
//! - `Value`: Parsed tree structure (the "struct" in StructFS)
//! - `Record`: Either raw bytes or parsed Value
//! - `Format`: Hint about wire format for codecs
//!
//! Use this layer for:
//! - Application routing based on validated paths
//! - Format-aware caching and transformation
//! - Working with structured data
//!
//! # Example
//!
//! ```rust
//! use structfs_core_store::{Reader, Writer, Record, Path, path};
//!
//! fn read_user(store: &mut dyn Reader) -> Result<Option<Record>, structfs_core_store::Error> {
//!     store.read(&path!("users/123"))
//! }
//! ```

// Allow code generated by the re-exported `path!` proc macro (which emits
// `::structfs_core_store::...` paths) to compile inside this crate too.
extern crate self as structfs_core_store;

pub use bytes::Bytes;

mod bridge;
mod combinators;
pub mod conformance;
mod error;
mod format;
mod lazy_record;
mod memory_store;
pub mod mount_store;
pub mod overlay_store;
mod path;
mod path_pattern;
pub mod path_trie;
mod record;
mod reference;
mod serde_impls;
mod traits;
mod value;

pub use bridge::{CoreToLL, LLToCore};
pub use combinators::{Cascade, Masked, ReadOnly, Rooted, Shared};
pub use error::{CodecErrorKind, CodecOperation, Error};
pub use format::Format;
pub use lazy_record::LazyRecord;
pub use memory_store::MemoryStore;
pub use path::{Path, PathComponent, PathError};
pub use path_pattern::PathPattern;
pub use path_trie::PathTrie;
pub use record::Record;
pub use reference::{Reference, TypeDescriptor, TypeInfo};
pub use traits::{Codec, NoCodec, Reader, Store, Writer};
pub use value::Value;

/// Compile-time validated path construction.
///
/// String literals are validated against the path grammar at compile time;
/// runtime expressions must be [`PathComponent`] values.
///
/// ```rust
/// use structfs_core_store::{path, PathComponent};
///
/// let p = path!("users/123/name");
/// assert_eq!(p.len(), 3);
///
/// let name = PathComponent::try_new("alice").unwrap();
/// let p = path!("users", name, "profile");
/// assert_eq!(p.to_string(), "users/alice/profile");
/// ```
pub use structfs_path_macro::path;

// Re-export LL types for convenience
pub use structfs_ll_store::{LLError, LLPath, LLReader, LLStore, LLWriter};

// Async support
#[cfg(feature = "async")]
mod async_traits;

#[cfg(feature = "async")]
mod async_bridge;

#[cfg(feature = "async")]
pub use async_traits::{
    AsyncReader, AsyncStore, AsyncWriter, DetachedFuture, DetachedReader, DetachedStore,
    DetachedWriter, SyncToAsync,
};

#[cfg(feature = "async")]
pub use async_bridge::{AsyncCoreToLL, AsyncLLToCore};

// Re-export async LL types when async feature is enabled
#[cfg(feature = "async")]
pub use structfs_ll_store::{AsyncLLReader, AsyncLLStore, AsyncLLWriter, SyncToAsyncLL};