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 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//! use std::rc::Rc;
22//!
23//! #[derive(Debug)]
24//! struct CommitInfo {
25//!     hash: String,
26//!     author: String,
27//! }
28//!
29//! let revisions = vec![
30//!     BlameRevision {
31//!         content: "line 1\nline 2",
32//!         metadata: Rc::new(CommitInfo {
33//!             hash: "abc123".to_string(),
34//!             author: "Alice".to_string(),
35//!         }),
36//!     },
37//!     BlameRevision {
38//!         content: "line 1\nline 2\nline 3",
39//!         metadata: Rc::new(CommitInfo {
40//!             hash: "def456".to_string(),
41//!             author: "Bob".to_string(),
42//!         }),
43//!     },
44//! ];
45//!
46//! let result = blame(&revisions).unwrap();
47//! for line in result.lines() {
48//!     println!("{}: {}", line.revision_metadata.author, line.content);
49//! }
50//! ```
51
52mod blame;
53mod types;
54
55pub use blame::{blame, blame_with_options};
56pub use types::{BlameError, BlameLine, BlameOptions, BlameResult, BlameRevision, DiffAlgorithm};