Skip to main content

Crate picante

Crate picante 

Source
Expand description

§picante

Async incremental query runtime for Rust.

Picante is inspired by Salsa, but built for Tokio-first pipelines. It provides:

  • inputs
  • interning
  • async derived queries
  • dependency tracking
  • cache persistence with facet and facet-postcard
  • debugging and observability tools

See the repository README and the crate docs for examples and usage details. Picante is an async incremental query runtime, inspired by Salsa but designed for Tokio-first pipelines.

Picante provides:

§Minimal example

use picante::{DerivedIngredient, DynIngredient, HasRuntime, IngredientLookup, IngredientRegistry, InputIngredient, QueryKindId, Runtime};
use std::sync::Arc;

#[derive(Default)]
struct Db {
    runtime: Runtime,
    ingredients: IngredientRegistry<Db>,
}

impl HasRuntime for Db {
    fn runtime(&self) -> &Runtime {
        &self.runtime
    }
}

impl IngredientLookup for Db {
    fn ingredient(&self, kind: QueryKindId) -> Option<&dyn DynIngredient<Self>> {
        self.ingredients.ingredient(kind)
    }
}

let db = Db::default();

let text: Arc<InputIngredient<String, String>> =
    Arc::new(InputIngredient::new(QueryKindId(1), "Text"));

let len: Arc<DerivedIngredient<Db, String, u64>> = {
    let text = text.clone();
    Arc::new(DerivedIngredient::new(QueryKindId(2), "Len", move |db, key| {
        let text = text.clone();
        Box::pin(async move {
            let s = text.get(db, &key)?.unwrap_or_default();
            Ok(s.len() as u64)
        })
    }))
};

text.set(&db, "a".into(), "hello".into());
assert_eq!(len.get(&db, "a".into()).await?, 5);

Re-exports§

pub use db::DynIngredient;
pub use db::IngredientLookup;
pub use db::IngredientRegistry;
pub use db::Touch;
pub use error::PicanteError;
pub use error::PicanteResult;
pub use ingredient::DerivedIngredient;
pub use ingredient::InputIngredient;
pub use ingredient::InternId;
pub use ingredient::InternedIngredient;
pub use key::Dep;
pub use key::DynKey;
pub use key::Key;
pub use key::QueryKindId;
pub use revision::Revision;
pub use runtime::HasRuntime;
pub use runtime::Runtime;
pub use runtime::RuntimeEvent;
pub use runtime::RuntimeId;

Modules§

db
Database integration traits used by Picante for precise revalidation.
debug
Debugging and observability tools for Picante incremental computation.
error
Error types used throughout Picante.
frame
Tokio task-local query frames used for dependency recording and cycle detection.
ingredient
Query ingredients (inputs, derived queries, and interning).
key
Query key encoding and erased identifiers used for dependency graphs.
persist
Cache persistence for Picante ingredients.
revision
Revision counters used for global invalidation.
runtime
Shared runtime state for a Picante database (revisions, notifications, etc.).
wal
Write-ahead log (WAL) for incremental cache persistence.

Attribute Macros§

db
Generate a database struct wiring together ingredients and runtime.
input
Generate an interned-key input “entity” from a struct definition.
interned
Generate an interned “entity” from a struct definition.
tracked
Generate a memoized derived query from an async function.