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 mut scan = Scan::new(&config);
scan.add(&PkgPath::new("mail/mutt")?);
let ctx = RunContext::new(Arc::new(AtomicBool::new(false)));
scan.start(&ctx)?;
let result = scan.resolve()?;
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 load_cached(
&mut self,
cached: IndexMap<PkgPath, Vec<ScanIndex>>,
) -> usize
pub fn load_cached( &mut self, cached: IndexMap<PkgPath, Vec<ScanIndex>>, ) -> usize
Load previously cached scan results.
For limited scans, only loads cached packages reachable from the configured pkgpaths initially, but keeps the full cache available for on-demand loading when new dependencies are discovered.
Returns the number of cached packages initially loaded.
pub fn start(&mut self, ctx: &RunContext) -> 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 scanned(&self) -> impl Iterator<Item = &ScanIndex>
pub fn scanned(&self) -> impl Iterator<Item = &ScanIndex>
Get all scanned packages (before resolution).
Sourcepub fn resolve(&mut self) -> Result<ScanResult>
pub fn resolve(&mut self) -> 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.
Note: This method consumes the internal scan state. Calling it multiple times will return empty results on subsequent calls.
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