Skip to content

Use this guide to add Sourcier to an existing Rust project and to configure its feature flags. Sourcier supports Rust 1.99 and later (Edition 2024); the MSRV is verified in CI across feature configurations.

Terminal
cargo add sourcier

Cargo adds the latest 2.0 release and enables the default features.

You only ever depend on sourcier. It re-exports the full API of the sourcier-core engine crate, which exists so the implementation can stay small and the facade stable.

Compile a three-line program that touches the public API:

use sourcier::{SourceFilesBuilder, SourceFilesMap};
let files = SourceFilesBuilder::<u8>::new()
.add_file("a.rs", b"fn a() {}")
.expect("capacity available")
.finalize()
.expect("no capacity issue");
let _: &str = files.get_path(1).expect("file present");
Terminal
cargo build

A successful build prints nothing. Any unresolved import error means the dependency did not resolve — check that Cargo.lock contains sourcier.

All features except parallel are enabled by default and forwarded to sourcier-core. Disable the ones you do not need for a leaner build:

Cargo.toml
[dependencies]
sourcier = { version = "2.0", default-features = false, features = ["view"] }

This keeps the line-offset index and byte extraction while dropping serialization and runtime statistics. See Feature flags for the full matrix and what each feature gates.