Skip to content

Incremental engine for long horizon agents 🌟 Star if you like it!

chore(rust-sdk): publish metadata, crate docs, README and a testing module (#2743)

LJ πŸ₯₯🌴76a03824f3ea
diff --git a/dev/run_cargo_test_sdk.sh b/dev/run_cargo_test_sdk.sh
index e28b41f8..0c78cd66 100755
--- a/dev/run_cargo_test_sdk.sh
+++ b/dev/run_cargo_test_sdk.sh
@@ -21,7 +21,7 @@ cargo check -p cocoindex --all-features --all-targets
# (cargo-clippy-sdk compiles it). Arguments narrow the run, e.g.
# `--test fs_live`.
SDK_TEST_FEATURES="azure_blob,bigquery,code_match,doris,embed_api,fs_live,google_drive,kafka,lancedb"
-SDK_TEST_FEATURES+=",oci_object_storage,postgres,snowflake,sqlite,text,turbopuffer,valkey"
+SDK_TEST_FEATURES+=",oci_object_storage,postgres,snowflake,sqlite,testing,text,turbopuffer,valkey"
# The zvec tests link the prebuilt `zvec_c_api` shared library that the
# `zvec-rust` build script downloads. On Windows Cargo does not put that DLL on
# the test binaries' search path (STATUS_DLL_NOT_FOUND), so the tests run on
diff --git a/rust/sdk/cocoindex/Cargo.toml b/rust/sdk/cocoindex/Cargo.toml
index 173f8fb4..b70e3145 100644
--- a/rust/sdk/cocoindex/Cargo.toml
+++ b/rust/sdk/cocoindex/Cargo.toml
@@ -4,6 +4,52 @@ version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
+description = "Declarative, incremental data pipelines: declare target states as a function of sources and CocoIndex keeps them in sync with minimal recomputation"
+readme = "README.md"
+repository = "https://github.com/cocoindex-io/cocoindex"
+homepage = "https://cocoindex.io"
+documentation = "https://docs.rs/cocoindex"
+keywords = ["incremental", "etl", "indexing", "pipeline", "embeddings"]
+categories = ["database", "asynchronous", "data-structures"]
+# The crate's own sources and docs. `tests/`, `benches/` and the showcase are
+# left out of the package: the tests need the workspace's fixtures and
+# services, and the benches need `bench-support`.
+include = ["/src", "/README.md", "/Cargo.toml"]
+
+[package.metadata.docs.rs]
+# Every feature whose build needs no network access (docs.rs blocks it). Left
+# out: `fastembed` (the ONNX Runtime binary is downloaded by `ort-sys`' build
+# script), `zvec` (`zvec-rust-sys` downloads the prebuilt `libzvec_c_api`) and
+# `bench-support` (internal hooks). `qdrant` needs `protoc`, which the docs.rs
+# build image ships.
+features = [
+ "fs_live",
+ "text",
+ "code_match",
+ "chrono",
+ "rust_decimal",
+ "embed_api",
+ "postgres",
+ "sqlite",
+ "doris",
+ "surrealdb",
+ "kafka",
+ "iggy",
+ "amazon_s3",
+ "google_drive",
+ "oci_object_storage",
+ "azure_blob",
+ "lancedb",
+ "qdrant",
+ "turbopuffer",
+ "bigquery",
+ "snowflake",
+ "neo4j",
+ "falkordb",
+ "valkey",
+ "testing",
+]
+rustdoc-args = ["--cfg", "docsrs"]
[features]
# Live LocalFS directory watching (`fs::DirWalker::live`), via the `notify`
@@ -149,12 +195,17 @@ valkey = ["dep:redis", "redis/tokio-native-tls-comp"]
# Zvec embedded vector-database target, through the `zvec-rust` bindings to the
# zvec C API. Its build script downloads the prebuilt `libzvec_c_api`.
zvec = ["dep:zvec-rust", "dep:base64", "chrono", "rust_decimal"]
+# Test helpers (`cocoindex::testing`): an `Environment` on a temporary
+# database path that is removed on drop. Pulls in `tempfile`.
+testing = ["dep:tempfile"]
# Extra core store hooks for the `state_store_read` bench (its
# `required-features`). Never enabled by production dependents.
bench-support = ["cocoindex_core/bench-support"]
[dependencies]
-cocoindex_macros = { path = "../cocoindex_macros" }
+cocoindex_macros = { path = "../cocoindex_macros", version = "0.1.0" }
+# Temporary database directories for `cocoindex::testing` (feature `testing`).
+tempfile = { version = "3", optional = true }
cocoindex_core = { path = "../../core", package = "cocoindex_core" }
cocoindex_utils = { path = "../../utils", package = "cocoindex_utils" }
# Language registry + shared `CodeSource` handle (`ops::text`, `ops::code`).
@@ -297,3 +348,25 @@ required-features = ["bench-support"]
[[bench]]
name = "entity_resolution"
harness = false
+
+# These tests build their environment with `cocoindex::testing`, so they need
+# the `testing` feature; without it Cargo skips them instead of failing to
+# compile (`cargo check --all-targets` with no features). A self
+# dev-dependency would enable the feature too, but it links the crate twice
+# into its own unit tests and breaks the `linkme` registry (duplicate
+# `COCO_FN_LOGIC`).
+[[test]]
+name = "batching_runner"
+required-features = ["testing"]
+
+[[test]]
+name = "deadline"
+required-features = ["testing"]
+
+[[test]]
+name = "detailed_stats"
+required-features = ["testing"]
+
+[[test]]
+name = "mount"
+required-features = ["testing"]
diff --git a/rust/sdk/cocoindex/README.md b/rust/sdk/cocoindex/README.md
new file mode 100644
index 00000000..3215afc1
--- /dev/null
+++ b/rust/sdk/cocoindex/README.md
@@ -0,0 +1,87 @@
+# cocoindex
+
+Declarative, incremental data pipelines in Rust.
+
+CocoIndex keeps a target in sync with its source. You declare what the output
+should look like (files, rows, vectors, graph nodes) as a function of the
+input, and the engine works out what changed since the last run and applies
+the minimal set of creates, updates and deletes. This crate is the Rust SDK;
+it runs the same core engine as the Python package
+[`cocoindex`](https://pypi.org/project/cocoindex/) and shares its concepts and
+state database.
+
+- [Documentation](https://cocoindex.io/docs), with the
+ [Rust quickstart](https://cocoindex.io/docs/getting_started/rust_quickstart)
+- [Showcase](https://github.com/cocoindex-io/cocoindex/blob/main/rust/sdk/SHOWCASE.md):
+ a tour of every part of the SDK
+- [Examples](https://github.com/cocoindex-io/cocoindex/tree/main/examples/rust)
+- [API reference](https://docs.rs/cocoindex)
+
+## Example
+
+A pipeline that upper-cases every `.txt` file under `./input` into `./output`.
+On the second run only the files that changed are processed, and a file
+removed from `./input` is removed from `./output`.
+
+```rust
+use cocoindex::prelude::*;
+
+// One processing component per file: it declares that file's output, so the
+// output is synced, and removed, with the file.
+#[cocoindex::function(memo)]
+async fn upper(ctx: &Ctx, file: FileEntry, target: DirTarget) -> Result<()> {
+ let text = file.content_str()?.to_uppercase();
+ target.declare_file(ctx, &file.key(), text.as_bytes())?;
+ Ok(())
+}
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ let app = App::open("upper_case", "./.cocoindex_db").await?;
+ let stats = app
+ .run(|ctx| async move {
+ let target = DirTarget::mount(&ctx, "./output")?;
+ let files = walk_items("./input", &["**/*.txt"])?;
+ mount_each!(files, |file| upper(ctx, file, target)).await?;
+ Ok(())
+ })
+ .await?;
+ println!("{stats}");
+ Ok(())
+}
+```
+
+## Features
+
+The crate has no default features. Every connector and op is behind a feature
+so that a pipeline compiles only what it uses.
+
+| Feature | Enables | Needs at build time |
+|---|---|---|
+| `text` | `ops::text`: language detection, recursive and separator chunking | a C compiler (tree-sitter grammars) |
+| `code_match` | `ops::code`: structural code matching over tree-sitter ASTs | a C compiler |
+| `fastembed` | `ops::sentence_transformers`, `ops::image`: local embeddings | the ONNX Runtime, downloaded by `ort-sys`; models download at run time |
+| `embed_api` | `ops::api`: embeddings and transcription over an OpenAI-compatible HTTP API | |
+| `fs_live` | `DirWalker::live`: follow a directory with native file events | |
+| `chrono`, `rust_decimal` | `MemoInput` for those crates' types | |
+| `postgres` | Postgres source and target (pgvector) | |
+| `sqlite` | SQLite target | |
+| `doris` | Apache Doris target | |
+| `surrealdb` | SurrealDB target | |
+| `lancedb` | LanceDB target (embedded) | |
+| `qdrant` | Qdrant target | `protoc` |
+| `turbopuffer` | turbopuffer target | |
+| `zvec` | Zvec target (embedded) | the prebuilt `libzvec_c_api`, downloaded by `zvec-rust-sys` |
+| `valkey` | Valkey/Redis (RediSearch) target | OpenSSL headers on Linux |
+| `neo4j`, `falkordb` | graph targets | |
+| `bigquery`, `snowflake` | data warehouse targets | |
+| `kafka`, `iggy` | message stream sources and targets | |
+| `amazon_s3`, `azure_blob`, `google_drive`, `oci_object_storage` | object store and drive sources | |
+| `testing` | `cocoindex::testing`: an `Environment` on a temporary database for tests | |
+
+Features that speak HTTP through `reqwest` use the platform's native TLS,
+which on Linux needs the OpenSSL development headers.
+
+## License
+
+Apache-2.0
diff --git a/rust/sdk/cocoindex/src/connectors/lancedb.rs b/rust/sdk/cocoindex/src/connectors/lancedb.rs
index f0c1fc00..609a6ebf 100644
--- a/rust/sdk/cocoindex/src/connectors/lancedb.rs
+++ b/rust/sdk/cocoindex/src/connectors/lancedb.rs
@@ -409,7 +409,7 @@ pub struct LanceTableTarget {
/// Build a composable [`TargetState`] for a LanceDB table (the spec constructor).
/// Pass it to [`declare_table_target`]/[`mount_table_target`] or the generic
-/// [`declare_target_state_with_child`]/[`mount_target`]. System-managed.
+/// [`crate::declare_target_state_with_child`]/[`mount_target`]. System-managed.
pub fn table_target(
ctx: &Ctx,
db: &ContextKey<LanceDatabase>,
diff --git a/rust/sdk/cocoindex/src/connectors/oci_object_storage.rs b/rust/sdk/cocoindex/src/connectors/oci_object_storage.rs
index 3081d19c..59c72927 100644
--- a/rust/sdk/cocoindex/src/connectors/oci_object_storage.rs
+++ b/rust/sdk/cocoindex/src/connectors/oci_object_storage.rs
@@ -1394,7 +1394,7 @@ struct OciEventDetails {
/// over the event type): a present object becomes an `update`, a `404` a
/// `delete`. Events are filtered by envelope type, namespace/bucket, the
/// prefix + path matcher, and an `eventTime` cutoff (snapshot time minus
-/// [`OCI_LIVE_SKEW_SECS`]; missing/unparseable/future times pass through).
+/// `OCI_LIVE_SKEW_SECS`; missing/unparseable/future times pass through).
/// An event is acknowledged to its [`LiveStream`] once the update or delete it
/// caused has synced (at once when it was filtered out), so a durable stream
/// commits its position only past processed events. Feed it to
diff --git a/rust/sdk/cocoindex/src/connectors/postgres.rs b/rust/sdk/cocoindex/src/connectors/postgres.rs
index 2bf3c8b2..2b365974 100644
--- a/rust/sdk/cocoindex/src/connectors/postgres.rs
+++ b/rust/sdk/cocoindex/src/connectors/postgres.rs
@@ -11,7 +11,7 @@
//! rows for use with `Ctx::mount_each`.
//!
//! Rows are written in batches: one parameterized `unnest` statement per
-//! chunk of [`ROWS_PER_STATEMENT`] rows (see [`RowStatements`]), the statements
+//! chunk of `ROWS_PER_STATEMENT` rows (see `RowStatements`), the statements
//! of a batch running concurrently over the pool.
use std::collections::{BTreeMap, BTreeSet};
@@ -1341,7 +1341,7 @@ async fn drop_table(db: &Database, pg_schema_name: Option<&str>, table_name: &st
const ROWS_PER_STATEMENT: usize = 2000;
/// Apply a batch of row mutations: upserts and deletes, each in statements of
-/// up to [`ROWS_PER_STATEMENT`] rows. The statements of a batch run
+/// up to `ROWS_PER_STATEMENT` rows. The statements of a batch run
/// concurrently, each on its own pool connection and committing on its own, as
/// the Python connector's do: a batch is not atomic, and a statement that
/// fails is retried by the next run.
@@ -2147,7 +2147,7 @@ const READ_BUFFER_ROWS: usize = 256;
/// The rows are read inside one `REPEATABLE READ, READ ONLY` transaction, so
/// the whole table is observed as one consistent snapshot, and they are
/// streamed from the server as the consumer takes them (Python's
-/// `PgTableSource.fetch_rows()` cursor): at most [`READ_BUFFER_ROWS`] rows are
+/// `PgTableSource.fetch_rows()` cursor): at most `READ_BUFFER_ROWS` rows are
/// held ahead of the consumer. Dropping the stream ends the read.
///
/// `T` must be `Deserialize` (column names map to struct fields; unknown columns
diff --git a/rust/sdk/cocoindex/src/connectors/qdrant.rs b/rust/sdk/cocoindex/src/connectors/qdrant.rs
index 3ad0c000..86cd0d56 100644
--- a/rust/sdk/cocoindex/src/connectors/qdrant.rs
+++ b/rust/sdk/cocoindex/src/connectors/qdrant.rs
@@ -894,8 +894,8 @@ pub async fn mount_collection_target_with_options(
/// Build a composable [`TargetState`] for a Qdrant collection (the spec
/// constructor). Pass it to the generic
-/// [`mount_target`](crate::target_state::mount_target) /
-/// [`declare_target_state_with_child`](crate::target_state::declare_target_state_with_child),
+/// [`mount_target`] /
+/// [`declare_target_state_with_child`],
/// or use [`declare_collection_target`]/[`mount_collection_target`].
pub fn collection_target(
ctx: &Ctx,
diff --git a/rust/sdk/cocoindex/src/connectors/turbopuffer.rs b/rust/sdk/cocoindex/src/connectors/turbopuffer.rs
index d0df6007..74120ffa 100644
--- a/rust/sdk/cocoindex/src/connectors/turbopuffer.rs
+++ b/rust/sdk/cocoindex/src/connectors/turbopuffer.rs
@@ -632,8 +632,8 @@ pub async fn mount_namespace_target_with_options(
/// Build a composable [`TargetState`] for a Turbopuffer namespace (the spec
/// constructor). Pass it to the generic
-/// [`mount_target`](crate::target_state::mount_target) /
-/// [`declare_target_state_with_child`](crate::target_state::declare_target_state_with_child),
+/// [`mount_target`] /
+/// [`declare_target_state_with_child`],
/// or use [`declare_namespace_target`]/[`mount_namespace_target`].
pub fn namespace_target(
ctx: &Ctx,
diff --git a/rust/sdk/cocoindex/src/deps.rs b/rust/sdk/cocoindex/src/deps.rs
index 23cb92c9..b6a9cb47 100644
--- a/rust/sdk/cocoindex/src/deps.rs
+++ b/rust/sdk/cocoindex/src/deps.rs
@@ -4,7 +4,7 @@
//! `logic_tracking = "self"` layers). They mirror the Python SDK's
//! `coco.LogicDep` / `use_logic_dep`, `coco.DataDep` / `use_data_dep` and
//! `coco.logic_propagated_to_callers`; the recording methods live on
-//! [`Ctx`](crate::Ctx) because Rust has no ambient component context.
+//! [`Ctx`] because Rust has no ambient component context.
//!
//! For a value every call of a function depends on, use the `deps = ...`
//! argument of `#[cocoindex::function]` instead.
diff --git a/rust/sdk/cocoindex/src/lib.rs b/rust/sdk/cocoindex/src/lib.rs
index 2f9fc426..c8429d41 100644
--- a/rust/sdk/cocoindex/src/lib.rs
+++ b/rust/sdk/cocoindex/src/lib.rs
@@ -1,3 +1,127 @@
+//! Declarative, incremental data pipelines.
+//!
+//! CocoIndex keeps a target in sync with its source. You declare what the
+//! output should look like (*target states*: files, rows, vectors, graph
+//! nodes) as a function of the input, and the engine works out what changed
+//! since the last run and applies the minimal set of creates, updates and
+//! deletes. The mental model is the one of React or a spreadsheet: declare the
+//! result, and the engine recomputes only what its inputs changed.
+//!
+//! This crate is the Rust SDK. It calls the same core engine as the Python
+//! package `cocoindex`, with the same state database, so the two SDKs share
+//! concepts one for one: an [`App`] with a main function, *processing
+//! components* mounted at stable component paths ([`mount!`], [`use_mount!`],
+//! [`mount_each!`]), memoized functions (`#[cocoindex::function(memo)]`),
+//! typed context resources ([`ContextKey`], [`context_key!`]) and target
+//! connectors ([`connectors`]).
+//!
+//! # Example
+//!
+//! A pipeline that upper-cases every `.txt` file under `./input` into
+//! `./output`. On the second run only the files that changed are processed,
+//! and a file removed from `./input` is removed from `./output`.
+//!
+//! ```no_run
+//! use cocoindex::prelude::*;
+//!
+//! // One processing component per file: it declares that file's output, so
+//! // the output is synced, and removed, with the file.
+//! #[cocoindex::function(memo)]
+//! async fn upper(ctx: &Ctx, file: FileEntry, target: DirTarget) -> Result<()> {
+//! let text = file.content_str()?.to_uppercase();
+//! target.declare_file(ctx, &file.key(), text.as_bytes())?;
+//! Ok(())
+//! }
+//!
+//! #[tokio::main]
+//! async fn main() -> Result<()> {
+//! let app = App::open("upper_case", "./.cocoindex_db").await?;
+//! let stats = app
+//! .run(|ctx| async move {
+//! let target = DirTarget::mount(&ctx, "./output")?;
+//! let files = walk_items("./input", &["**/*.txt"])?;
+//! mount_each!(files, |file| upper(ctx, file, target)).await?;
+//! Ok(())
+//! })
+//! .await?;
+//! println!("{stats}");
+//! Ok(())
+//! }
+//! ```
+//!
+//! `#[cocoindex::app]`, `#[cocoindex::lifespan]` and `#[cocoindex::main]`
+//! register apps for the `cocoindex` command-line tool for Rust projects
+//! (`rust/cli` in the repository), which runs, previews and inspects them.
+//! The [showcase](https://github.com/cocoindex-io/cocoindex/blob/main/rust/sdk/SHOWCASE.md)
+//! walks through every part of the SDK; the
+//! [documentation site](https://cocoindex.io/docs) has the concepts and the
+//! quickstart.
+//!
+//! # Modules
+//!
+//! - [`mod@app`]: [`Environment`], [`App`], updates, previews and dropping state.
+//! - [`ctx`]: [`Ctx`], the handle a component uses to mount children, memoize
+//! work, read context and declare target states.
+//! - [`memo`]: [`MemoInput`], the identity of a memoized argument.
+//! - [`deps`]: dependencies a function declares beyond its arguments.
+//! - [`batched`]: batched function calls and the [`Batched`] input type.
+//! - [`runner`]: GPU runners for batched functions.
+//! - [`target_state`]: the target-state model and the [`TargetHandler`]
+//! trait a connector implements.
+//! - [`user_state`]: per-component state kept between runs.
+//! - [`live_component`]: long-running components that react to source
+//! changes.
+//! - [`resources`]: files and directories, chunks, embedders, id generation,
+//! rate limiting and schemas.
+//! - [`ops`]: text splitting, code matching, embedding and transcription.
+//! - [`connectors`]: sources and targets for external systems, one per
+//! feature.
+//! - [`inspect`]: read the state database of an app.
+//! - [`cli`]: the protocol between a user binary and the `cocoindex` CLI.
+//! - [`prelude`]: the names most pipelines use.
+//!
+//! # Features
+//!
+//! The crate has no default features. Every connector and op is behind a
+//! feature so that a pipeline compiles only what it uses.
+//!
+//! | Feature | Enables | Needs at build time |
+//! |---|---|---|
+//! | `text` | [`ops::text`]: language detection, recursive and separator chunking | a C compiler (tree-sitter grammars) |
+//! | `code_match` | [`ops::code`]: structural code matching over tree-sitter ASTs | a C compiler |
+//! | `fastembed` | `ops::sentence_transformers`, `ops::image`: local embeddings | the ONNX Runtime, downloaded by `ort-sys` (network); models download at run time |
+//! | `embed_api` | [`ops::api`]: embeddings and transcription over an OpenAI-compatible HTTP API | |
+//! | `fs_live` | [`DirWalker::live`]: follow a directory with native file events | |
+//! | `chrono`, `rust_decimal` | [`MemoInput`] for those crates' types | |
+//! | `postgres` | [`connectors::postgres`] source and target (pgvector) | |
+//! | `sqlite` | [`connectors::sqlite`] target | |
+//! | `doris` | [`connectors::doris`] target (MySQL protocol + Stream Load) | |
+//! | `surrealdb` | [`connectors::surrealdb`] target | |
+//! | `lancedb` | [`connectors::lancedb`] target (embedded) | |
+//! | `qdrant` | [`connectors::qdrant`] target | `protoc` |
+//! | `turbopuffer` | [`connectors::turbopuffer`] target | |
+//! | `zvec` | `connectors::zvec` target (embedded) | the prebuilt `libzvec_c_api`, downloaded by `zvec-rust-sys` (network) |
+//! | `valkey` | [`connectors::valkey`] target (Valkey/Redis with RediSearch) | OpenSSL headers on Linux (native TLS) |
+//! | `neo4j` | [`connectors::neo4j`] graph target | |
+//! | `falkordb` | [`connectors::falkordb`] graph target | |
+//! | `bigquery` | [`connectors::bigquery`] target | |
+//! | `snowflake` | [`connectors::snowflake`] target | |
+//! | `kafka` | [`connectors::kafka`] source and target | |
+//! | `iggy` | [`connectors::iggy`] source and target | |
+//! | `amazon_s3` | [`connectors::amazon_s3`] source (S3 and S3-compatible stores) | |
+//! | `azure_blob` | [`connectors::azure_blob`] source | |
+//! | `google_drive` | [`connectors::gdrive`] source | |
+//! | `oci_object_storage` | [`connectors::oci_object_storage`] source | |
+//! | `testing` | [`testing`]: an [`Environment`] on a temporary database for tests | |
+//!
+//! Features that speak HTTP through `reqwest` (`embed_api`, `doris`,
+//! `google_drive`, `oci_object_storage`, `azure_blob`, `turbopuffer`,
+//! `bigquery`, `snowflake`) use the platform's native TLS, which on Linux
+//! needs the OpenSSL development headers.
+//!
+//! The documentation on docs.rs is built with every feature whose build needs
+//! no network access (all but `fastembed` and `zvec`).
+
extern crate self as cocoindex;
pub mod app;
@@ -50,6 +174,8 @@ pub(crate) mod sql_ident;
pub mod statediff;
mod stats;
pub mod target_state;
+#[cfg(feature = "testing")]
+pub mod testing;
mod typemap;
pub mod user_state;
@@ -68,6 +194,9 @@ pub use entity_resolution::{
};
pub use error::{Error, Result};
pub use memo::MemoInput;
+// The fingerprint type in public signatures ([`FileMetadata::content_fingerprint`],
+// [`FnDeps::get`]); users cannot name it through `cocoindex_utils`.
+pub use cocoindex_utils::fingerprint::Fingerprint;
pub use resources::file::{
DecodeErrors, FileContentCache, FileLike, FileMetadata, FilePath, FilePathMatcher,
FileSourceItem, MatchAllFilePathMatcher, PatternFilePathMatcher,
@@ -112,15 +241,11 @@ pub use resources::chunk::{Chunk, TextPosition};
pub use resources::embedder::Embedder;
pub use resources::live_map::{LiveMap, LiveMapKey};
pub use resources::rate_limit::RateLimiter;
-pub use resources::view::{SegmentKind, SourceView, ViewSegment};
-// The content/memo fingerprint type: `memo::key_fingerprint_result`,
-// `FileMetadata::content_fingerprint` and `FileLike::content_fingerprint`
-// return it, and `MemoInput` accepts a precomputed one.
-pub use cocoindex_utils::fingerprint::Fingerprint;
pub use resources::schema::{
MultiVectorSchema, MultiVectorSchemaProvider, VectorElementType, VectorSchema,
VectorSchemaProvider,
};
+pub use resources::view::{SegmentKind, SourceView, ViewSegment};
pub use statediff::{
CompositeTrackingRecord, DiffAction, ManagedBy, ManagedTargetOptions, MutualTrackingRecord,
TrackingRecordTransition, diff, diff_composite, resolve_system_transition,
diff --git a/rust/sdk/cocoindex/src/logic.rs b/rust/sdk/cocoindex/src/logic.rs
index a0532cd1..644381a7 100644
--- a/rust/sdk/cocoindex/src/logic.rs
+++ b/rust/sdk/cocoindex/src/logic.rs
@@ -1,8 +1,8 @@
//! Link-time registry of `#[coco::function]` logic fingerprints.
//!
-//! Each `#[cocoindex::function]` adds one [`FnLogicEntry`] to the [`COCO_FN_LOGIC`]
+//! Each `#[cocoindex::function]` adds one [`FnLogicEntry`] to the `COCO_FN_LOGIC`
//! distributed slice (collected across crates at link time). At app/environment
-//! startup, [`register_all_fn_logic`] computes each function's logic fingerprint
+//! startup, `register_all_fn_logic` computes each function's logic fingerprint
//! and registers it into the engine's logic set.
//!
//! Why this matters: a memoized caller's entry stores the logic fingerprints of
diff --git a/rust/sdk/cocoindex/src/memo.rs b/rust/sdk/cocoindex/src/memo.rs
index 0d061638..98020793 100644
--- a/rust/sdk/cocoindex/src/memo.rs
+++ b/rust/sdk/cocoindex/src/memo.rs
@@ -1028,8 +1028,7 @@ pub fn key_bytes_result<T: Serialize + ?Sized>(value: &T) -> Result<Vec<u8>> {
rmp_serde::to_vec_named(value).map_err(Error::from)
}
-#[doc(hidden)]
-pub fn key_fingerprint_result<T: Serialize + ?Sized>(value: &T) -> Result<Fingerprint> {
+pub(crate) fn key_fingerprint_result<T: Serialize + ?Sized>(value: &T) -> Result<Fingerprint> {
Fingerprint::from(value).map_err(|e| Error::engine(format!("fingerprint error: {e}")))
}
diff --git a/rust/sdk/cocoindex/src/ops/mod.rs b/rust/sdk/cocoindex/src/ops/mod.rs
index 184fa957..f62ff5f4 100644
--- a/rust/sdk/cocoindex/src/ops/mod.rs
+++ b/rust/sdk/cocoindex/src/ops/mod.rs
@@ -8,9 +8,9 @@
//! chunking.
//! - [`code`] (`code_match` feature): structural code matching over reusable
//! parsed ASTs (`CodeAst`, `CodePattern`, `match_code`, `index_terms`).
-//! - [`sentence_transformers`] (`fastembed` feature): local sentence-transformer
+//! - `sentence_transformers` (`fastembed` feature): local sentence-transformer
//! embeddings.
-//! - [`image`] (`fastembed` feature): local image (CLIP) embeddings.
+//! - `image` (`fastembed` feature): local image (CLIP) embeddings.
//! - [`api`] (`embed_api` feature): remote embeddings/transcription over an
//! OpenAI-compatible HTTP API.
diff --git a/rust/sdk/cocoindex/src/testing.rs b/rust/sdk/cocoindex/src/testing.rs
new file mode 100644
index 00000000..8535194e
--- /dev/null
+++ b/rust/sdk/cocoindex/src/testing.rs
@@ -0,0 +1,86 @@
+//! Test helpers (feature `testing`): an [`Environment`] on a temporary
+//! database directory that is removed when the helper is dropped.
+//!
+//! The Rust counterpart of the Python test suite's
+//! `common.create_test_env(__file__)`: every test gets a fresh, uniquely
+//! named state database, so tests never share state and leave nothing behind.
+//!
+//! ```no_run
+//! use cocoindex::prelude::*;
+//! use cocoindex::testing::TestEnv;
+//!
+//! # async fn run() -> Result<()> {
+//! let env = TestEnv::new().await?;
+//! let app = env.app("my_test").await?;
+//! app.update(|_ctx| async move { Ok(()) }).await?;
+//! # Ok(())
+//! # }
+//! ```
+
+use std::ops::Deref;
+use std::path::Path;
+
+use tempfile::TempDir;
+
+use crate::app::{Environment, EnvironmentBuilder};
+use crate::error::Result;
+
+/// An [`Environment`] whose state database lives in a temporary directory.
+///
+/// Derefs to the [`Environment`], so [`Environment::app`] and the other
+/// environment methods are available directly. The directory, and the
+/// database in it, are removed when the value is dropped.
+pub struct TestEnv {
+ // Declared before `dir` so the environment closes before the directory
+ // is removed.
+ env: Environment,
+ dir: TempDir,
+}
+
+impl TestEnv {
+ /// Build an environment with default settings on a new temporary
+ /// directory.
+ pub async fn new() -> Result<Self> {
+ Self::from_builder(Environment::builder()).await
+ }
+
+ /// Build an environment from `builder`, on a new temporary directory.
+ /// The builder's `db_path`, if set, is replaced.
+ ///
+ /// Use this to provide context values or an exception handler:
+ ///
+ /// ```no_run
+ /// # use cocoindex::prelude::*;
+ /// # use cocoindex::testing::TestEnv;
+ /// # async fn run() -> Result<()> {
+ /// let env = TestEnv::from_builder(Environment::builder().provide(42u32)).await?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub async fn from_builder(builder: EnvironmentBuilder) -> Result<Self> {
+ let dir = tempfile::Builder::new()
+ .prefix("cocoindex_test_")
+ .tempdir()?;
+ let env = builder.db_path(dir.path().join("db")).build().await?;
+ Ok(Self { env, dir })
+ }
+
+ /// The temporary directory. The state database is under it; a test can
+ /// put its own input and output files beside it.
+ pub fn dir(&self) -> &Path {
+ self.dir.path()
+ }
+
+ /// The environment itself, for a call that needs an owned clone.
+ pub fn env(&self) -> &Environment {
+ &self.env
+ }
+}
+
+impl Deref for TestEnv {
+ type Target = Environment;
+
+ fn deref(&self) -> &Environment {
+ &self.env
+ }
+}
diff --git a/rust/sdk/cocoindex/tests/batching_runner.rs b/rust/sdk/cocoindex/tests/batching_runner.rs
index f9fcc338..85baf8f1 100644
--- a/rust/sdk/cocoindex/tests/batching_runner.rs
+++ b/rust/sdk/cocoindex/tests/batching_runner.rs
@@ -6,18 +6,15 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{LazyLock, Mutex};
use std::time::Duration;
+use cocoindex::testing::TestEnv;
use cocoindex::{App, Batched, Ctx, Error, GPU, GPURunner, Result, configure_gpu_pool};
use tokio::sync::Notify;
use tokio::time::sleep;
-async fn temp_app(name: &str) -> (App, tempfile::TempDir) {
- let dir = tempfile::tempdir().unwrap();
- let app = App::builder(name)
- .db_path(dir.path().join("lmdb"))
- .build()
- .await
- .unwrap();
- (app, dir)
+async fn temp_app(name: &str) -> (App, TestEnv) {
+ let env = TestEnv::new().await.unwrap();
+ let app = env.app(name).await.unwrap();
+ (app, env)
}
/// The GPU pool is process-wide, so tests that configure it take turns.
@@ -68,7 +65,7 @@ async fn limited(_ctx: &Ctx, items: Vec<i64>) -> Result<Vec<i64>> {
#[tokio::test]
async fn retry_with_smaller_batch_splits_until_success() {
- let (app, _dir) = temp_app("split_until_success").await;
+ let (app, _env) = temp_app("split_until_success").await;
app.update(|ctx| async move {
// The first call runs inline and blocks, so the next four queue into
// one batch of four behind it.
@@ -132,7 +129,7 @@ async fn poisonable(_ctx: &Ctx, items: Vec<i64>) -> Result<Vec<i64>> {
#[tokio::test]
async fn retry_with_smaller_batch_isolates_poison_item() {
- let (app, _dir) = temp_app("split_poison_item").await;
+ let (app, _env) = temp_app("split_poison_item").await;
app.update(|ctx| async move {
let blocker_ctx = ctx.clone();
let blocker = tokio::spawn(async move { poisonable(&blocker_ctx, 1).await });
@@ -173,7 +170,7 @@ async fn always_split(_ctx: &Ctx, _items: Vec<i64>) -> Result<Vec<i64>> {
#[tokio::test]
async fn retry_with_smaller_batch_at_size_one_fails_with_cause() {
- let (app, _dir) = temp_app("split_size_one").await;
+ let (app, _env) = temp_app("split_size_one").await;
let err = app
.update(|ctx| async move { always_split(&ctx, 1).await })
.await
@@ -201,7 +198,7 @@ async fn memo_limited(_ctx: &Ctx, items: Vec<i64>) -> Result<Vec<i64>> {
#[tokio::test]
async fn memo_batching_memoizes_results_of_retried_halves() {
- let (app, _dir) = temp_app("split_memo").await;
+ let (app, _env) = temp_app("split_memo").await;
async fn run(app: &App) -> Result<Vec<i64>> {
app.update(|ctx| async move {
let blocker_ctx = ctx.clone();
@@ -268,7 +265,7 @@ async fn batched_adapter_splits_on_retry_with_smaller_batch() {
)
});
- let (app, _dir) = temp_app("split_batched_adapter").await;
+ let (app, _env) = temp_app("split_batched_adapter").await;
app.update(|ctx| async move {
let blocker_ctx = ctx.clone();
let blocker = tokio::spawn(async move { BATCHED.call(&blocker_ctx, 1).await });
@@ -355,7 +352,7 @@ async fn gpu_runner_serializes_calls_on_one_gpu() {
WHOLE_GPU_IN_FLIGHT.reset();
WHOLE_GPU_SEEN.lock().unwrap().clear();
- let (app, _dir) = temp_app("runner_one_gpu").await;
+ let (app, _env) = temp_app("runner_one_gpu").await;
let outputs = app
.update(|ctx| async move {
assert_eq!(
@@ -384,7 +381,7 @@ async fn gpu_runner_spreads_calls_over_two_gpus() {
WHOLE_GPU_IN_FLIGHT.reset();
WHOLE_GPU_SEEN.lock().unwrap().clear();
- let (app, _dir) = temp_app("runner_two_gpus").await;
+ let (app, _env) = temp_app("runner_two_gpus").await;
app.update(|ctx| async move {
let calls = (0..4).map(|item| whole_gpu(&ctx, item));
futures::future::join_all(calls)
@@ -420,7 +417,7 @@ async fn fractional_gpu_runner_shares_one_gpu_between_two_calls() {
configure_gpu_pool(NonZeroUsize::new(1).unwrap());
HALF_GPU_IN_FLIGHT.reset();
- let (app, _dir) = temp_app("runner_half_gpu").await;
+ let (app, _env) = temp_app("runner_half_gpu").await;
let outputs = app
.update(|ctx| async move {
let calls = (0..3).map(|item| half_gpu(&ctx, item));
@@ -463,7 +460,7 @@ async fn gpu_runner_holds_the_gpu_per_physical_batch_and_per_retried_half() {
GPU_BATCH_IN_FLIGHT.reset();
GPU_BATCHES.lock().unwrap().clear();
- let (app, _dir) = temp_app("runner_batching").await;
+ let (app, _env) = temp_app("runner_batching").await;
let outputs = app
.update(|ctx| async move {
let calls = [5, -1, 6, 7].map(|item| gpu_batch(&ctx, item));
diff --git a/rust/sdk/cocoindex/tests/deadline.rs b/rust/sdk/cocoindex/tests/deadline.rs
index 3ba22eba..c839e0ff 100644
--- a/rust/sdk/cocoindex/tests/deadline.rs
+++ b/rust/sdk/cocoindex/tests/deadline.rs
@@ -4,6 +4,7 @@ use std::sync::{
};
use std::time::Duration;
+use cocoindex::testing::TestEnv;
use cocoindex::{
App, Error, StableKey, TargetAction, TargetActionSink, TargetHandler, TargetReconcileOutput,
UpdateOptions, declare_target_state, register_root_target_states_provider,
@@ -44,14 +45,10 @@ impl Drop for TestClockGuard {
}
}
-async fn temp_app(name: &str) -> (App, tempfile::TempDir) {
- let dir = tempfile::tempdir().unwrap();
- let app = App::builder(name)
- .db_path(dir.path().join("lmdb"))
- .build()
- .await
- .unwrap();
- (app, dir)
+async fn temp_app(name: &str) -> (App, TestEnv) {
+ let env = TestEnv::new().await.unwrap();
+ let app = env.app(name).await.unwrap();
+ (app, env)
}
fn assert_deadline(err: Error) {
@@ -140,7 +137,7 @@ async fn rust_sdk_deadline_conformance_subset() {
// Nested deadlines are min-composed on the immutable Ctx carrier, and the
// SDK exposes the same typed error that the Rust core produces.
- let (app, _dir) = temp_app("sdk_deadline_nested").await;
+ let (app, _env) = temp_app("sdk_deadline_nested").await;
app.update(|ctx| async move {
assert!(!ctx.has_deadline());
let outer = ctx.with_timeout(Duration::from_secs(10));
@@ -164,7 +161,7 @@ async fn rust_sdk_deadline_conformance_subset() {
// narrowed deadline. The core pre-memo/entry checkpoint catches an already
// expired child before its body can run.
clock.reset();
- let (app, _dir) = temp_app("sdk_deadline_use_mount_inherit").await;
+ let (app, _env) = temp_app("sdk_deadline_use_mount_inherit").await;
let child_body_started = Arc::new(AtomicBool::new(false));
let err = app
.update({
@@ -194,7 +191,7 @@ async fn rust_sdk_deadline_conformance_subset() {
// Background/live-style components are isolated. The child processor Ctx
// sees no deadline even though the parent has one.
clock.reset();
- let (app, _dir) = temp_app("sdk_deadline_mount_isolate").await;
+ let (app, _env) = temp_app("sdk_deadline_mount_isolate").await;
let child_saw_no_deadline = Arc::new(AtomicBool::new(false));
app.update_with_options(
UpdateOptions {
@@ -224,7 +221,7 @@ async fn rust_sdk_deadline_conformance_subset() {
// reports the first error in input order. Replacing join_all with
// try_join_all makes this assertion fail because the slow future is dropped.
clock.reset();
- let (app, _dir) = temp_app("sdk_deadline_map_drains").await;
+ let (app, _env) = temp_app("sdk_deadline_map_drains").await;
let slow_started = Arc::new(AtomicBool::new(false));
let slow_released = Arc::new(Notify::new());
let slow_completed = Arc::new(AtomicBool::new(false));
@@ -285,7 +282,7 @@ async fn rust_sdk_deadline_conformance_subset() {
// If a processor expires after declaring target states, the core
// post-body/pre-submit checkpoint stops submit; the sink is never called.
clock.reset();
- let (app, _dir) = temp_app("sdk_deadline_before_submit").await;
+ let (app, _env) = temp_app("sdk_deadline_before_submit").await;
let applied = Arc::new(Mutex::new(Vec::<WriteAction>::new()));
let err = app
.update_with_options(
@@ -317,7 +314,7 @@ async fn rust_sdk_deadline_conformance_subset() {
// advances the clock past the caller's deadline, the write still lands and
// the update result reports the caller's expired deadline afterward.
clock.reset();
- let (app, _dir) = temp_app("sdk_deadline_sink_isolate").await;
+ let (app, _env) = temp_app("sdk_deadline_sink_isolate").await;
let applied = Arc::new(Mutex::new(Vec::<WriteAction>::new()));
let err = app
.update_with_options(
@@ -355,7 +352,7 @@ async fn rust_sdk_deadline_conformance_subset() {
// before the memoized child body can execute again.
clock.reset();
MEMO_CHILD_CALLS.store(0, Ordering::SeqCst);
- let (app, _dir) = temp_app("sdk_deadline_memo_hit").await;
+ let (app, _env) = temp_app("sdk_deadline_memo_hit").await;
app.update(|ctx| async move {
let out = cocoindex::use_mount!(memo_deadline_child(ctx)).await?;
assert_eq!(out, 7);
@@ -392,7 +389,7 @@ async fn use_mount_each_drains_started_siblings_on_deadline_error() {
// work after A has already failed, so B's committed row below is only
// possible if use_mount_each drained instead of cancelling.
let _clock = TestClockGuard::new();
- let (app, _dir) = temp_app("mount_each_drain").await;
+ let (app, _env) = temp_app("mount_each_drain").await;
let applied: Arc<Mutex<Vec<WriteAction>>> = Arc::new(Mutex::new(Vec::new()));
let gate = Arc::new(Notify::new());
diff --git a/rust/sdk/cocoindex/tests/detailed_stats.rs b/rust/sdk/cocoindex/tests/detailed_stats.rs
index f60f1206..8758ac7d 100644
--- a/rust/sdk/cocoindex/tests/detailed_stats.rs
+++ b/rust/sdk/cocoindex/tests/detailed_stats.rs
@@ -1,16 +1,13 @@
//! Tests for the detailed per-component stats surface (`ComponentStats`,
//! `UpdateStats`, `UpdateStatus`) β€” Python parity with `cocoindex.UpdateStats`.
+use cocoindex::testing::TestEnv;
use cocoindex::{App, ComponentStats, UpdateStats, UpdateStatus};
-async fn temp_app(name: &str) -> (App, tempfile::TempDir) {
- let dir = tempfile::tempdir().unwrap();
- let app = App::builder(name)
- .db_path(dir.path().join("lmdb"))
- .build()
- .await
- .unwrap();
- (app, dir)
+async fn temp_app(name: &str) -> (App, TestEnv) {
+ let env = TestEnv::new().await.unwrap();
+ let app = env.app(name).await.unwrap();
+ (app, env)
}
// ─── Pure-data tests (no engine) ─────────────────────────────────────────────
@@ -120,7 +117,7 @@ fn update_status_default_is_running() {
#[tokio::test]
async fn detailed_stats_after_completion_are_ready_and_consistent() {
- let (app, _dir) = temp_app("detailed_stats_consistency").await;
+ let (app, _env) = temp_app("detailed_stats_consistency").await;
let mut handle = app
.start_update(|ctx| async move {
@@ -168,7 +165,7 @@ async fn detailed_stats_after_completion_are_ready_and_consistent() {
#[tokio::test]
async fn detailed_stats_snapshot_before_completion_is_running() {
- let (app, _dir) = temp_app("detailed_stats_running").await;
+ let (app, _env) = temp_app("detailed_stats_running").await;
// Before driving the handle to Done, status should be Running.
let handle = app
diff --git a/rust/sdk/cocoindex/tests/mount.rs b/rust/sdk/cocoindex/tests/mount.rs
index acec7f29..52c99455 100644
--- a/rust/sdk/cocoindex/tests/mount.rs
+++ b/rust/sdk/cocoindex/tests/mount.rs
@@ -10,6 +10,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use cocoindex::prelude::*;
+use cocoindex::testing::TestEnv;
use cocoindex::{Environment, ExceptionSource};
use tokio::sync::Notify;
@@ -44,33 +45,23 @@ fn key_str(key: &StableKey) -> String {
}
}
-async fn temp_app(name: &str) -> (App, tempfile::TempDir) {
- let dir = tempfile::tempdir().unwrap();
- let app = App::builder(name)
- .db_path(dir.path().join(".cocoindex_db"))
- .build()
- .await
- .unwrap();
- (app, dir)
+async fn temp_app(name: &str) -> (App, TestEnv) {
+ let env = TestEnv::new().await.unwrap();
+ let app = env.app(name).await.unwrap();
+ (app, env)
}
/// An app whose environment installs `handler` as the global exception
/// handler, the way a Python lifespan's `builder.set_exception_handler` does.
-async fn temp_app_with_handler<H>(name: &str, handler: H) -> (App, tempfile::TempDir)
+async fn temp_app_with_handler<H>(name: &str, handler: H) -> (App, TestEnv)
where
H: Fn(&Error, &ExceptionContext) -> Result<()> + Send + Sync + 'static,
{
- let dir = tempfile::tempdir().unwrap();
- let app = Environment::builder()
- .db_path(dir.path().join(".cocoindex_db"))
- .exception_handler(handler)
- .build()
- .await
- .unwrap()
- .app(name)
+ let env = TestEnv::from_builder(Environment::builder().exception_handler(handler))
.await
.unwrap();
- (app, dir)
+ let app = env.app(name).await.unwrap();
+ (app, env)
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
@@ -197,7 +188,7 @@ impl std::error::Error for DeadLetter {}
/// states to sync.
#[tokio::test]
async fn mount_returns_before_child_finishes_and_ready_waits_for_sync() {
- let (app, _dir) = temp_app("mount_background").await;
+ let (app, _env) = temp_app("mount_background").await;
let log = new_log();
let sink = recording_sink(log.clone());
let release = Arc::new(Notify::new());
@@ -243,7 +234,7 @@ async fn mount_returns_before_child_finishes_and_ready_waits_for_sync() {
/// nobody awaits their handles; a child no longer mounted is cleaned up.
#[tokio::test]
async fn mount_children_sync_before_update_completes_and_are_garbage_collected() {
- let (app, _dir) = temp_app("mount_gc").await;
+ let (app, _env) = temp_app("mount_gc").await;
let log = new_log();
async fn run(app: &App, log: &Log, keys: Vec<&'static str>) {
@@ -276,7 +267,7 @@ async fn mount_children_sync_before_update_completes_and_are_garbage_collected()
/// the parent, its siblings and `ready()` all succeed (the Python default).
#[tokio::test]
async fn mount_failure_without_handler_is_logged_not_propagated() {
- let (app, _dir) = temp_app("mount_no_handler").await;
+ let (app, _env) = temp_app("mount_no_handler").await;
let log = new_log();
let sink = recording_sink(log.clone());
@@ -311,7 +302,7 @@ async fn mount_failure_without_handler_is_logged_not_propagated() {
#[tokio::test]
async fn global_exception_handler_invoked_for_background_mount() {
let seen: Arc<Mutex<Vec<SeenFailure>>> = Arc::new(Mutex::new(Vec::new()));
- let (app, _dir) = temp_app_with_handler("mount_global_handler", {
+ let (app, _env) = temp_app_with_handler("mount_global_handler", {
let seen = seen.clone();
move |err, exc| {
seen.lock().unwrap().push((
@@ -350,7 +341,7 @@ async fn global_exception_handler_invoked_for_background_mount() {
#[tokio::test]
async fn scoped_handler_overrides_global_and_falls_back_on_handler_error() {
let calls: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(Vec::new()));
- let (app, _dir) = temp_app_with_handler("mount_scoped_handler", {
+ let (app, _env) = temp_app_with_handler("mount_scoped_handler", {
let calls = calls.clone();
move |err, exc| {
calls
@@ -398,7 +389,7 @@ async fn scoped_handler_overrides_global_and_falls_back_on_handler_error() {
#[tokio::test]
async fn scoped_handler_applies_only_to_mounts_from_the_scoped_ctx() {
let calls: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(Vec::new()));
- let (app, _dir) = temp_app_with_handler("mount_scoped_only", {
+ let (app, _env) = temp_app_with_handler("mount_scoped_only", {
let calls = calls.clone();
move |_err, exc| {
calls
@@ -449,7 +440,7 @@ async fn scoped_handler_applies_only_to_mounts_from_the_scoped_ctx() {
/// match on its type.
#[tokio::test]
async fn handler_error_propagates_through_ready_with_its_type() {
- let (app, _dir) = temp_app_with_handler("mount_handler_propagates", |err, _exc| {
+ let (app, _env) = temp_app_with_handler("mount_handler_propagates", |err, _exc| {
Err(Error::user(DeadLetter(err.to_string())))
})
.await;
@@ -489,7 +480,7 @@ async fn fail_under_subpath(_ctx: &Ctx, _name: String) -> Result<()> {
#[tokio::test]
async fn with_subpath_nests_child_paths() {
let seen: Arc<Mutex<Vec<SeenPaths>>> = Arc::new(Mutex::new(Vec::new()));
- let (app, _dir) = temp_app_with_handler("mount_subpath", {
+ let (app, _env) = temp_app_with_handler("mount_subpath", {
let seen = seen.clone();
move |_err, exc| {
seen.lock()
@@ -537,7 +528,7 @@ async fn with_subpath_nests_child_paths() {
/// scope at the prefix, finds its state unchanged instead of recreating it.
#[tokio::test]
async fn with_subpath_is_the_same_component_as_the_direct_path() {
- let (app, _dir) = temp_app("mount_subpath_identity").await;
+ let (app, _env) = temp_app("mount_subpath_identity").await;
let log = new_log();
let sink = recording_sink(log.clone());
@@ -593,7 +584,7 @@ async fn with_subpath_is_the_same_component_as_the_direct_path() {
/// because the state belongs to the component, not to the subpath.
#[tokio::test]
async fn use_state_is_rejected_on_a_subpath_ctx() {
- let (app, _dir) = temp_app("mount_subpath_use_state").await;
+ let (app, _env) = temp_app("mount_subpath_use_state").await;
let message = app
.update(|ctx| async move {
@@ -627,7 +618,7 @@ async fn bg_count(_ctx: &Ctx, _n: u32) -> Result<()> {
/// component is skipped on the next run, and a changed argument re-runs it.
#[tokio::test]
async fn mount_macro_skips_unchanged_component_across_runs() {
- let (app, _dir) = temp_app("mount_macro_skip").await;
+ let (app, _env) = temp_app("mount_macro_skip").await;
async fn run(app: &App, n: u32) {
app.update(move |ctx| async move {
diff --git a/rust/sdk/cocoindex_macros/Cargo.toml b/rust/sdk/cocoindex_macros/Cargo.toml
index 8b95fa4c..ee973190 100644
--- a/rust/sdk/cocoindex_macros/Cargo.toml
+++ b/rust/sdk/cocoindex_macros/Cargo.toml
@@ -4,6 +4,13 @@ version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
+description = "Proc macros for the cocoindex crate: #[function], #[app], #[lifespan], #[main], mount!, use_mount!, mount_each!"
+repository = "https://github.com/cocoindex-io/cocoindex"
+homepage = "https://cocoindex.io"
+documentation = "https://docs.rs/cocoindex_macros"
+keywords = ["cocoindex", "incremental", "pipeline", "macros"]
+categories = ["development-tools::procedural-macro-helpers"]
+include = ["/src", "/Cargo.toml"]
[lib]
proc-macro = true
diff --git a/rust/sdk/cocoindex_macros/src/lib.rs b/rust/sdk/cocoindex_macros/src/lib.rs
index df35aaa4..e3a1a661 100644
--- a/rust/sdk/cocoindex_macros/src/lib.rs
+++ b/rust/sdk/cocoindex_macros/src/lib.rs
@@ -1952,7 +1952,7 @@ fn logical_type_tokens(ty: &Type, attr: &SchemaFieldAttr) -> TokenStream2 {
/// `Option<T>` fields become nullable columns; everything else is `NOT NULL`.
/// Use `#[coco(vector)]` with `TableSchema::with_vector_dim(...)` when the
/// dimension is available only at runtime, or `#[coco(vector = N)]` when it is
-/// a compile-time constant. See [`cocoindex::row_schema`] for the other field
+/// a compile-time constant. See `cocoindex::row_schema` for the other field
/// attributes.
///
/// Unsigned integers map to the next signed width, so `u64` and `usize` map to
@@ -2086,7 +2086,7 @@ fn type_ends_with(ty: &Type, name: &str) -> bool {
}
/// Register an app entry point with the binary, so `cocoindex update` / `drop`
-/// and [`Environment::from_registered`] can find it by name.
+/// and `Environment::from_registered` can find it by name.
///
/// The function keeps its signature and stays callable (`app.run(app_main)`).
/// It must be `async fn name(ctx: Ctx) -> Result<T>` β€” `Ctx` by value. The