Expand description
§Sassi
Sassi is a typed cache substrate for Rust applications with composable predicate algebra and cross-runtime trait queries. It is built for when cached Rust data stops being just a key-value lookup and starts becoming typed local application state.
It provides an in-memory pool (Punnu<T>) that lets you
look up domain objects by identity, refresh them, and query a local
view using composable predicate filtering (BasicPredicate<T> + MemQ)
—without tying that view to an ORM, a web framework, or a database client.
Sassi is framework-neutral: usable from native services, workers,
libraries, and wasm32-unknown-unknown applications without a
backend-specific dependency. Predicates compose with &, |, ^,
! operators and evaluate through the same in-memory path on every
supported target.
Beta release (v0.1.0-beta.4). The core public surface is available now:
Cacheable identities, pools, in-memory scopes, lazy fetch helpers,
TTL/LRU policy, event streams, and atomic delta application.
§Quick tour
The same body is mirrored in sassi/examples/quick_tour.rs
(CI-verified by the workspace cargo clippy --all-targets gate) and in
the lead README.md.
use sassi::{Cacheable, MemQ, Punnu};
#[derive(sassi::Cacheable)]
struct User {
id: i64,
age: u32,
is_active: bool,
}
async fn run() {
// 1. Build the in-memory pool and populate it.
let users = Punnu::<User>::builder().build();
users
.insert(User { id: 1, age: 32, is_active: true })
.await
.unwrap();
// 2. Query local state with composable predicates.
let adults = users
.scope(vec![MemQ::filter_basic(
User::fields().age.gte(18) & User::fields().is_active.eq(true),
)])
.take(10)
.collect();
assert_eq!(adults.len(), 1);
}The derive requires a field literally named id; types whose identifier
uses a different name (e.g. user_id) must hand-implement Cacheable
until v0.2 adds #[cacheable(id)].
Re-exports§
pub use backend::BackendInvalidation;pub use backend::BackendInvalidationStream;pub use backend::BackendKeyspace;pub use backend::CacheBackend;pub use backend::FileBackend;pub use backend::MemoryBackend;pub use cacheable::Cacheable;pub use cacheable::Field;pub use error::BackendError;pub use error::FetchError;pub use error::InsertError;pub use error::PunnuSnapshotError;pub use error::WireFormatError;pub use jsahibon::JFiniteF64;pub use jsahibon::JObject;pub use jsahibon::JSahibON;pub use jsahibon::JSahibONError;pub use predicate::BasicPredicate;pub use predicate::FieldPredicate;pub use predicate::IntoBasicPredicate;pub use predicate::JCompareOp;pub use predicate::JInPolarity;pub use predicate::JOrderedScalar;pub use predicate::JPath;pub use predicate::JSahibONFieldRef;pub use predicate::JSahibONOptionFieldRef;pub use predicate::JSahibONPathRef;pub use predicate::JSahibONPredicateBody;pub use predicate::JSahibONValueRef;pub use predicate::JScalar;pub use predicate::JScalarKind;pub use predicate::JScalarValue;pub use predicate::JTypeKind;pub use predicate::LookupOp;pub use predicate::MemQ;pub use predicate::PresentField;pub use predicate::evaluate_jsahibon_predicate;pub use punnu::BackendFailureMode;pub use punnu::CacheTier;pub use punnu::DeltaApplyStats;pub use punnu::DeltaPunnuFetcher;pub use punnu::DeltaQuery;pub use punnu::DeltaRefreshHandle;pub use punnu::DeltaResult;pub use punnu::EventReason;pub use punnu::InvalidationReason;pub use punnu::OnConflict;pub use punnu::Punnu;pub use punnu::PunnuBuilder;pub use punnu::PunnuConfig;pub use punnu::PunnuEvent;pub use punnu::PunnuFetcher;pub use punnu::PunnuMetrics;pub use punnu::PunnuScope;pub use punnu::RefreshHandle;pub use punnu::RefreshMode;pub use punnu::TenantKey;pub use punnu::UpdateResult;pub use punnu::PunnuRestoreStats;pub use punnu::SnapshotMode;pub use sassi::Sassi;pub use watermark::DeltaSyncCacheable;pub use watermark::MonotonicWatermark;
Modules§
- backend
- Pluggable L2 cache backend interfaces and built-in implementations.
- cacheable
Cacheabletrait +Fieldaccessor — the identity contract for entries stored in aPunnu.- error
- Library-wide error types.
- jsahibon
- Portable JSON values for Sassi cache and wire boundaries.
- predicate
- Predicate algebras.
- punnu
Punnu<T>— typed in-memory pool with composable predicate filtering, an event stream, single-flight fetch coalescing, opt-in TTL, and pluggable L2 backends.- sassi
- Cross-type orchestration for typed
Punnupools. - watermark
- Monotonic watermark contracts for delta-sync refreshes.
- wire
- Binary wire container for L2 cache backends and other byte-shaped transfers.
Functions§
- version
- The crate version, surfaced from
CARGO_PKG_VERSION. Useful for runtime diagnostics. Sassi’s binary wire container uses its ownwire::WIRE_FORMAT_MAJOR, not the crate semver version.
Type Aliases§
- Instant
- Cross-target monotonic clock instant. See module-level docs.
Attribute Macros§
- trait_
impl - Attribute macro for registering a trait implementation with
Sassi::all_impl::<dyn Trait>().
Derive Macros§
- Cacheable
- Derive macro for
sassi::Cacheable.