Skip to main content

Scan

Struct Scan 

Source
pub struct Scan { /* private fields */ }
Expand description

Package dependency scanner.

Implementations§

Source§

impl Scan

Source

pub fn new(config: &Config) -> Scan

Source

pub fn add(&mut self, pkgpath: &PkgPath)

Source

pub fn is_full_tree(&self) -> bool

Returns true if this is a full tree scan.

Source

pub fn set_full_scan_complete(&mut self)

Mark that a previous full tree scan completed successfully.

Source

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).

Source

pub fn start(&mut self, db: &Database, scope: &mut SandboxScope) -> Result<()>

Source

pub fn scan_errors(&self) -> impl Iterator<Item = &str>

Returns scan failures as formatted error strings.

Source

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, filtering inactive packages for limited scans.

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.

Source

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§

Source§

impl Debug for Scan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Scan

Source§

fn default() -> Scan

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send,