blame_rs/
lib.rs

1//! # blame-rs
2//!
3//! A Rust library for line-by-line authorship tracking in revisioned text content.
4//!
5//! This crate provides a Git-style blame/annotate algorithm that determines which revision
6//! introduced each line in a document by analyzing a sequence of revisions.
7//!
8//! ## Features
9//!
10//! - **Generic metadata**: Attach any metadata type to revisions (commit hashes, authors, timestamps, etc.)
11//! - **Multiple diff algorithms**: Support for Myers and Patience algorithms via the `similar` crate
12//! - **Forward tracking**: Efficiently traces line origins from oldest to newest revision
13//! - **Zero-copy optimization**: Uses string slices (`&str`) to avoid unnecessary allocations
14//! - **Shared metadata**: Reference-counted metadata sharing reduces memory usage
15//! - **Pre-allocated vectors**: Minimizes heap allocations during processing
16//!
17//! ## Example
18//!
19//! ```rust
20//! use blame_rs::{blame, BlameRevision};
21//!
22//! #[derive(Clone, Debug)]
23//! struct CommitInfo {
24//!     hash: String,
25//!     author: String,
26//! }
27//!
28//! let revisions = vec![
29//!     BlameRevision {
30//!         content: "line 1\nline 2",
31//!         metadata: CommitInfo {
32//!             hash: "abc123".to_string(),
33//!             author: "Alice".to_string(),
34//!         },
35//!     },
36//!     BlameRevision {
37//!         content: "line 1\nline 2\nline 3",
38//!         metadata: CommitInfo {
39//!             hash: "def456".to_string(),
40//!             author: "Bob".to_string(),
41//!         },
42//!     },
43//! ];
44//!
45//! let result = blame(&revisions).unwrap();
46//! for line in result.lines() {
47//!     println!("{}: {}", line.revision_metadata.author, line.content);
48//! }
49//! ```
50
51mod blame;
52mod types;
53
54pub use blame::{blame, blame_with_options};
55pub use types::{BlameError, BlameLine, BlameOptions, BlameResult, BlameRevision, DiffAlgorithm};