bob/lib.rs
1/*
2 * Copyright (c) 2025 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 stats;
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/// Shared context for a build or scan run.
37pub struct RunContext {
38 /// Optional stats collector for performance metrics.
39 pub stats: Option<Arc<stats::Stats>>,
40 /// Flag to signal graceful shutdown.
41 pub shutdown: Arc<AtomicBool>,
42}
43
44impl RunContext {
45 pub fn new(shutdown: Arc<AtomicBool>) -> Self {
46 Self { stats: None, shutdown }
47 }
48
49 pub fn with_stats(mut self, stats: Arc<stats::Stats>) -> Self {
50 self.stats = Some(stats);
51 self
52 }
53}
54
55// Re-export main types for convenience
56pub use action::{Action, ActionType, FSType};
57pub use build::{Build, BuildOptions, BuildOutcome, BuildResult, BuildSummary};
58pub use config::{Config, Options, Pkgsrc, Sandboxes};
59pub use db::Database;
60pub use report::write_html_report;
61pub use sandbox::Sandbox;
62pub use scan::{
63 ResolvedIndex, Scan, ScanFailure, ScanResult, SkipReason, SkippedPackage,
64};
65pub use stats::Stats;
66
67// Re-export init for CLI use
68pub use init::Init;