Skip to main content

run

Function run 

Source
pub async fn run(config: &Config) -> Result<()>
Expand description

Runs the full gitprint pipeline and writes a PDF to config.output_path.

Accepts a single file, a git repository (optionally scoped to a subdirectory), or a plain directory. The output always goes to config.output_path.

§Errors

Returns an error if the path does not exist, git operations fail, the theme is invalid, or writing the PDF fails.

§Examples

use gitprint::types::{Config, PaperSize};
use std::path::PathBuf;

let config = Config {
    repo_path: PathBuf::from("."),
    output_path: PathBuf::from("out.pdf"),
    // ... other fields
};
gitprint::run(&config).await.unwrap();

Concurrency model:

  • Single-file mode: highlighter init (CPU, spawn_blocking) runs concurrently with file content read and last-modified date fetch (both I/O).
  • Multi-file mode: git metadata, tracked-file list, date map, and highlighter init all run concurrently via tokio::join!; highlighter uses spawn_blocking to keep tokio worker threads free for I/O.
  • File reads use a tokio JoinSet (I/O-bound parallelism).
  • Syntax highlighting uses rayon par_iter via spawn_blocking (CPU-bound).
  • Cover render, dummy TOC count, and dummy tree count run in parallel via nested rayon::join — all three are CPU-bound and mutually independent.
  • Final TOC and tree renders also run in parallel via rayon::join.