Skip to content
The Sourcier logo — three stacked layers connected by a glowing path

Sourcier

Compact and efficient source file mapping and position tracking for Rust. Register source files once, hand out stable numeric ids, and pack every span — file id, line and column — into a single `u64`.

Sourcier is built for diagnostics-heavy tools — compilers, linters, formatters, language servers and code editors — that need positions which are cheap to build, compare, store and serialize, yet still resolve back to the exact bytes of the file they point at. Instead of dragging String paths and four usize fields through every diagnostic, you pack the whole span into one u64 and keep the heavy data in a single immutable registry.

Learn the golden path

Follow the tutorial to register files, finalize a map, and extract the exact bytes of a span in about ten minutes.

Solve a specific task

Task-oriented guides cover installation, registration, packed positions, byte views, shared statistics, errors and performance tuning.

Look something up

Reference pages document the full API surface, the stable u64 bit layouts, feature flags and every error variant.

Understand the design

Explanation pages walk through the two-phase lifecycle, the verified path index and the safety guarantees that shape the API.

  • One u64 per span. File id, start line, start column, end line and end column are bit-packed together. Positions are Copy, cache-friendly, order naturally as integers and survive serialization round trips bit-exactly.
  • Constant-time lookups. After finalization, path to id, id to path and id to content are all O(1); line and column navigation is O(log n).
  • Byte-accurate views. With the default view feature, a position resolves to the exact bytes it covers, including multi-line spans and line terminators.
  • No unsafe code. The whole workspace is #![forbid(unsafe_code)], error enums are #[non_exhaustive], and the FileId trait is sealed.