pub struct Scan { /* private fields */ }Expand description
Package dependency scanner.
Implementations§
Source§impl Scan
impl Scan
pub fn new(config: &Config) -> Scan
pub fn add(&mut self, pkgpath: &PkgPath)
Sourcepub fn is_full_tree(&self) -> bool
pub fn is_full_tree(&self) -> bool
Returns true if this is a full tree scan.
Sourcepub fn set_full_scan_complete(&mut self)
pub fn set_full_scan_complete(&mut self)
Mark that a previous full tree scan completed successfully.
Sourcepub fn init_from_db(&mut self, db: &Database) -> Result<(usize, usize)>
pub fn init_from_db(&mut self, db: &Database) -> Result<(usize, usize)>
Initialize scan from database, checking what’s already scanned. Returns (cached_count, pending_deps_count) where pending_deps_count is the number of dependencies discovered but not yet scanned (from interrupted scans).
pub fn start(&mut self, db: &Database, scope: &mut SandboxScope) -> Result<()>
Sourcepub fn scan_errors(&self) -> impl Iterator<Item = &str>
pub fn scan_errors(&self) -> impl Iterator<Item = &str>
Returns scan failures as formatted error strings.
Sourcepub fn resolve(&mut self, scan_data: Vec<ScanIndex>) -> Result<ScanSummary>
pub fn resolve(&mut self, scan_data: Vec<ScanIndex>) -> Result<ScanSummary>
Resolve dependency patterns to available package names.
Takes scanned package data (from make pbulk-index) and resolves
dependency patterns like “perl>=5.0” to specific packages like
“perl-5.38.0”. Returns a ScanSummary classifying each package as
Buildable, Skipped, or ScanFail.
§Algorithm
Phase 1 - Load and classify: Load all scan indexes from the database. For each package, record any PKG_SKIP_REASON or PKG_FAIL_REASON as a skip reason. For limited scans (non-full-tree), seed the “active” set with packages from initial_pkgpaths.
Phase 2 - Setup lookups: Build a pkgbase map for O(1) candidate lookup by package base name (e.g., “perl” -> [perl-5.38.0, perl-5.36.0]). Initialize a match cache to memoize resolved patterns.
Phase 3 - Resolution loop: For each package (active packages only for limited scans), resolve each dependency pattern:
- Check the cache for a previous match
- Find candidates via pkgbase map (fast) or full scan (for wildcards)
- Select the best match using pbulk’s version comparison rules
- Record unresolved dependencies as skip reasons
- For limited scans, activate matched dependencies and iterate until no new packages become active
Phase 4 - Propagate failures: Walk the dependency graph to mark packages with failed/skipped dependencies as IndirectFail/IndirectSkip.
Phase 5 - Build results: Transform the packages map into a
Vec
Phase 6 - Finalize: Check for circular dependencies, store resolved dependency edges in the database for reverse lookups, return summary.
§Limited vs Full Tree Scans
Full tree scans resolve all packages in pkgsrc. Limited scans (when
packages are explicitly added via add()) only resolve packages from
initial_pkgpaths and their transitive dependencies, matching pbulk’s
presolve behavior. This avoids scanning/resolving thousands of unneeded
packages when building a small subset.
Sourcepub fn resolve_with_report(
&mut self,
db: &Database,
strict: bool,
) -> Result<ScanSummary>
pub fn resolve_with_report( &mut self, db: &Database, strict: bool, ) -> Result<ScanSummary>
Resolve dependencies and report results.
Loads scan data from database, resolves dependencies, stores resolved
dependencies back to database, and reports any unresolved dependency
errors. Optionally bails if strict is true.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scan
impl !RefUnwindSafe for Scan
impl Send for Scan
impl Sync for Scan
impl Unpin for Scan
impl !UnwindSafe for Scan
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