pub struct Scan { /* private fields */ }Expand description
Package dependency scanner.
Discovers all dependencies for a set of packages and resolves them into a buildable set with proper ordering.
§Usage
- Create a
ScanwithScan::new - Add packages to scan with
Scan::add - Run the scan with
Scan::start - Resolve dependencies with
Scan::resolve
§Example
let config = Config::load(None, false)?;
let db_path = config.logdir().join("bob").join("bob.db");
let db = Database::open(&db_path)?;
let mut scan = Scan::new(&config);
scan.add(&PkgPath::new("mail/mutt")?);
let ctx = RunContext::new(Arc::new(AtomicBool::new(false)));
scan.start(&ctx, &db)?;
let result = scan.resolve(&db)?;
println!("Found {} buildable packages", result.buildable.len());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, ctx: &RunContext, db: &Database) -> Result<bool>
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 scan_failures(&self) -> &[(PkgPath, String)]
pub fn scan_failures(&self) -> &[(PkgPath, String)]
Returns scan failures with pkgpath information.
Sourcepub fn resolve(&mut self, db: &Database) -> Result<ScanResult>
pub fn resolve(&mut self, db: &Database) -> Result<ScanResult>
Resolve the list of scanned packages, by ensuring all of the Depend
patterns in all_depends match a found package, and that there are no
circular dependencies. The best match for each is stored in the
depends for the package in question.
Return a ScanResult containing buildable packages and skipped packages.
Also stores resolved dependencies in the database for fast reverse lookups.
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