pub struct Database { /* private fields */ }Expand description
SQLite database for scan and build caching.
Implementations§
Source§impl Database
impl Database
Sourcepub fn begin_transaction(&self) -> Result<()>
pub fn begin_transaction(&self) -> Result<()>
Begin a transaction.
Sourcepub fn store_package(&self, pkgpath: &str, index: &ScanIndex) -> Result<i64>
pub fn store_package(&self, pkgpath: &str, index: &ScanIndex) -> Result<i64>
Store a package from scan results.
Sourcepub fn store_scan_pkgpath(
&self,
pkgpath: &str,
indexes: &[ScanIndex],
) -> Result<()>
pub fn store_scan_pkgpath( &self, pkgpath: &str, indexes: &[ScanIndex], ) -> Result<()>
Store scan results for a pkgpath.
Sourcepub fn get_package_by_name(&self, pkgname: &str) -> Result<Option<PackageRow>>
pub fn get_package_by_name(&self, pkgname: &str) -> Result<Option<PackageRow>>
Get package by name.
Sourcepub fn get_pkgname(&self, package_id: i64) -> Result<String>
pub fn get_pkgname(&self, package_id: i64) -> Result<String>
Get pkgname by package ID.
Sourcepub fn get_packages_by_path(&self, pkgpath: &str) -> Result<Vec<PackageRow>>
pub fn get_packages_by_path(&self, pkgpath: &str) -> Result<Vec<PackageRow>>
Get packages by pkgpath.
Sourcepub fn is_pkgpath_scanned(&self, pkgpath: &str) -> Result<bool>
pub fn is_pkgpath_scanned(&self, pkgpath: &str) -> Result<bool>
Check if pkgpath is scanned.
Sourcepub fn get_scanned_pkgpaths(&self) -> Result<HashSet<String>>
pub fn get_scanned_pkgpaths(&self) -> Result<HashSet<String>>
Get all scanned pkgpaths.
Sourcepub fn get_unscanned_dependencies(&self) -> Result<HashSet<String>>
pub fn get_unscanned_dependencies(&self) -> Result<HashSet<String>>
Get pkgpaths that are referenced as dependencies but haven’t been scanned yet. These are dependencies that were discovered during scanning but the scan was interrupted before they could be processed.
Sourcepub fn count_packages(&self) -> Result<i64>
pub fn count_packages(&self) -> Result<i64>
Count of scanned packages.
Sourcepub fn count_scan(&self) -> Result<i64>
pub fn count_scan(&self) -> Result<i64>
Count of scanned pkgpaths.
Sourcepub fn get_all_packages(&self) -> Result<Vec<PackageRow>>
pub fn get_all_packages(&self) -> Result<Vec<PackageRow>>
Get all packages (lightweight).
Sourcepub fn get_buildable_packages(&self) -> Result<Vec<PackageRow>>
pub fn get_buildable_packages(&self) -> Result<Vec<PackageRow>>
Get all buildable packages (no skip/fail reason).
Sourcepub fn get_full_scan_index(&self, package_id: i64) -> Result<ScanIndex>
pub fn get_full_scan_index(&self, package_id: i64) -> Result<ScanIndex>
Load full ScanIndex for a package.
Sourcepub fn get_all_scan_indexes(&self) -> Result<Vec<(i64, ScanIndex)>>
pub fn get_all_scan_indexes(&self) -> Result<Vec<(i64, ScanIndex)>>
Load all ScanIndex data in one query.
Sourcepub fn get_scan_index_by_name(&self, pkgname: &str) -> Result<Option<ScanIndex>>
pub fn get_scan_index_by_name(&self, pkgname: &str) -> Result<Option<ScanIndex>>
Load full ScanIndex by pkgname.
Sourcepub fn clear_scan(&self) -> Result<()>
pub fn clear_scan(&self) -> Result<()>
Clear all scan data.
Sourcepub fn store_resolved_dependencies_batch(
&self,
deps: &[(i64, i64)],
) -> Result<()>
pub fn store_resolved_dependencies_batch( &self, deps: &[(i64, i64)], ) -> Result<()>
Store resolved dependencies in batch.
Sourcepub fn get_transitive_reverse_deps(&self, package_id: i64) -> Result<Vec<i64>>
pub fn get_transitive_reverse_deps(&self, package_id: i64) -> Result<Vec<i64>>
Get all transitive reverse dependencies using recursive CTE.
Sourcepub fn clear_resolved_depends(&self) -> Result<()>
pub fn clear_resolved_depends(&self) -> Result<()>
Clear all resolved dependencies.
Sourcepub fn store_build_result(
&self,
package_id: i64,
result: &BuildResult,
) -> Result<()>
pub fn store_build_result( &self, package_id: i64, result: &BuildResult, ) -> Result<()>
Store a build result by package ID.
Sourcepub fn store_build_by_name(&self, result: &BuildResult) -> Result<()>
pub fn store_build_by_name(&self, result: &BuildResult) -> Result<()>
Store a build result by pkgname.
Sourcepub fn get_build_result(&self, package_id: i64) -> Result<Option<BuildResult>>
pub fn get_build_result(&self, package_id: i64) -> Result<Option<BuildResult>>
Get build result for a package.
Sourcepub fn count_build(&self) -> Result<i64>
pub fn count_build(&self) -> Result<i64>
Count of build results.
Sourcepub fn delete_build_by_name(&self, pkgname: &str) -> Result<bool>
pub fn delete_build_by_name(&self, pkgname: &str) -> Result<bool>
Delete build result for a pkgname.
Sourcepub fn delete_build_by_pkgpath(&self, pkgpath: &str) -> Result<usize>
pub fn delete_build_by_pkgpath(&self, pkgpath: &str) -> Result<usize>
Delete build results by pkgpath.
Sourcepub fn clear_builds(&self) -> Result<usize>
pub fn clear_builds(&self) -> Result<usize>
Clear all build results.
Sourcepub fn get_all_build_results(&self) -> Result<Vec<BuildResult>>
pub fn get_all_build_results(&self) -> Result<Vec<BuildResult>>
Get all build results from the database.
Sourcepub fn count_breaks_for_failed(&self) -> Result<HashMap<String, usize>>
pub fn count_breaks_for_failed(&self) -> Result<HashMap<String, usize>>
Count how many packages are broken by each failed package. Returns a map from pkgname to the count of packages that depend on it.
Sourcepub fn get_total_build_duration(&self) -> Result<Duration>
pub fn get_total_build_duration(&self) -> Result<Duration>
Get total build duration from all builds.
Sourcepub fn get_prefailed_packages(
&self,
) -> Result<Vec<(String, Option<String>, String)>>
pub fn get_prefailed_packages( &self, ) -> Result<Vec<(String, Option<String>, String)>>
Get pre-failed packages (those with skip_reason or fail_reason but no build result). Returns (pkgname, pkgpath, reason).
Sourcepub fn get_indirect_failures(
&self,
) -> Result<Vec<(String, Option<String>, String)>>
pub fn get_indirect_failures( &self, ) -> Result<Vec<(String, Option<String>, String)>>
Get packages without build results that depend on failed packages. Returns (pkgname, pkgpath, failed_deps) where failed_deps is comma-separated. Excludes packages that have skip_reason or fail_reason (they’re pre-failed). Only lists root failures (direct failures), not indirect failures.
Sourcepub fn mark_failure_cascade(
&self,
package_id: i64,
reason: &str,
duration: Duration,
) -> Result<usize>
pub fn mark_failure_cascade( &self, package_id: i64, reason: &str, duration: Duration, ) -> Result<usize>
Mark a package and all its transitive reverse dependencies as failed. Returns the count of packages marked.
Sourcepub fn full_scan_complete(&self) -> bool
pub fn full_scan_complete(&self) -> bool
Check if a full tree scan has been completed.
Sourcepub fn set_full_scan_complete(&self) -> Result<()>
pub fn set_full_scan_complete(&self) -> Result<()>
Mark a full tree scan as complete.
Sourcepub fn clear_full_scan_complete(&self) -> Result<()>
pub fn clear_full_scan_complete(&self) -> Result<()>
Clear the full tree scan complete marker.
Sourcepub fn store_pkgsrc_env(&self, env: &PkgsrcEnv) -> Result<()>
pub fn store_pkgsrc_env(&self, env: &PkgsrcEnv) -> Result<()>
Store the pkgsrc environment to the database. Errors if already present as this should only ever be done once.
Sourcepub fn load_pkgsrc_env(&self) -> Result<PkgsrcEnv>
pub fn load_pkgsrc_env(&self) -> Result<PkgsrcEnv>
Load the pkgsrc environment from the database.
Sourcepub fn get_successful_packages(&self) -> Result<Vec<String>>
pub fn get_successful_packages(&self) -> Result<Vec<String>>
Get all package names with successful build outcomes.
Sourcepub fn execute_raw(&self, sql: &str) -> Result<()>
pub fn execute_raw(&self, sql: &str) -> Result<()>
Execute arbitrary SQL and print results.
Auto Trait Implementations§
impl !Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl !Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more