pub struct Resolver { /* private fields */ }Expand description
Greedy dependency resolver.
The algorithm walks the dependency tree breadth-first, always picking the highest version that satisfies each requested semver range. When two different parts of the tree request the same package with compatible ranges the already-resolved version is reused; when an incompatible range is encountered we keep the first resolved version (similar to npm flat-mode) and emit a warning.
Implementations§
Source§impl Resolver
impl Resolver
Sourcepub fn new(registry: Arc<RegistryClient>) -> Self
pub fn new(registry: Arc<RegistryClient>) -> Self
Create a new resolver backed by the given registry client.
Sourcepub fn with_overrides(
registry: Arc<RegistryClient>,
overrides: HashMap<String, String>,
) -> Self
pub fn with_overrides( registry: Arc<RegistryClient>, overrides: HashMap<String, String>, ) -> Self
Create a new resolver with overrides for forced version resolution.
Sourcepub fn with_workspace(
registry: Arc<RegistryClient>,
overrides: HashMap<String, String>,
workspace_packages: HashMap<String, (String, PathBuf)>,
) -> Self
pub fn with_workspace( registry: Arc<RegistryClient>, overrides: HashMap<String, String>, workspace_packages: HashMap<String, (String, PathBuf)>, ) -> Self
Create a new resolver with workspace package information.
Sourcepub fn set_auto_install_peers(&mut self, enabled: bool)
pub fn set_auto_install_peers(&mut self, enabled: bool)
Enable or disable automatic peer dependency installation.
Sourcepub async fn resolve(
&self,
root_deps: &HashMap<String, String>,
) -> Result<DependencyGraph>
pub async fn resolve( &self, root_deps: &HashMap<String, String>, ) -> Result<DependencyGraph>
Resolve a set of root dependencies into a flat dependency graph.
root_deps maps package names to semver range strings, exactly as
they appear in package.json under dependencies.
Uses a batch-drain BFS: drains up to 32 entries from the queue, fetches all missing metadata concurrently, then processes the batch.
Auto Trait Implementations§
impl !Freeze for Resolver
impl !RefUnwindSafe for Resolver
impl Send for Resolver
impl !Sync for Resolver
impl Unpin for Resolver
impl UnsafeUnpin for Resolver
impl !UnwindSafe for Resolver
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