Skip to main content

bob/
lib.rs

1/*
2 * Copyright (c) 2026 Jonathan Perkin <jonathan@perkin.org.uk>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#![cfg_attr(not(doctest), doc = include_str!("../README.md"))]
18
19pub mod action;
20pub mod build;
21pub mod config;
22pub mod db;
23pub mod report;
24pub mod sandbox;
25pub mod scan;
26pub mod summary;
27
28// Internal modules - exposed for binary use but not primary API
29mod init;
30pub mod logging;
31mod tui;
32
33use std::sync::Arc;
34use std::sync::atomic::AtomicBool;
35
36/// Error indicating the operation was interrupted (e.g., by Ctrl+C).
37#[derive(Debug)]
38pub struct Interrupted;
39
40impl std::fmt::Display for Interrupted {
41    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42        write!(f, "Interrupted")
43    }
44}
45
46impl std::error::Error for Interrupted {}
47
48/// Shared context for a build or scan run.
49#[derive(Clone, Debug)]
50pub struct RunContext {
51    /// Flag to signal graceful shutdown.
52    pub shutdown: Arc<AtomicBool>,
53}
54
55impl RunContext {
56    pub fn new(shutdown: Arc<AtomicBool>) -> Self {
57        Self { shutdown }
58    }
59}
60
61// Re-export main types for convenience
62pub use action::{Action, ActionType, FSType};
63pub use build::{Build, BuildCounts, BuildOptions, BuildOutcome, BuildResult, BuildSummary};
64pub use config::{Config, Options, Pkgsrc, PkgsrcEnv, Sandboxes};
65pub use db::Database;
66pub use report::write_html_report;
67pub use sandbox::Sandbox;
68pub use scan::{ResolvedPackage, Scan, ScanResult, ScanSummary, SkipReason, SkippedCounts};
69pub use summary::generate_pkg_summary;
70
71// Re-export init for CLI use
72pub use init::Init;