pub struct DependencyResolver {
pub registered_plugins: HashMap<String, Vec<SemVer>>,
}Expand description
Resolves a set of plugin dependencies to a concrete version selection.
§Algorithm
- For each dependency, narrow the acceptable version set by intersecting all constraints that target the same plugin.
- From the resulting range, pick the highest available version that satisfies the combined constraint.
- Perform a topological sort over the dependency graph to detect cycles and produce a safe load order.
Fields§
§registered_plugins: HashMap<String, Vec<SemVer>>Registered plugin versions: plugin_id → sorted Vec<SemVer>.
Implementations§
Source§impl DependencyResolver
impl DependencyResolver
Sourcepub fn register(&mut self, plugin_id: impl Into<String>, versions: Vec<SemVer>)
pub fn register(&mut self, plugin_id: impl Into<String>, versions: Vec<SemVer>)
Register all available versions of a plugin.
Versions need not be provided in sorted order.
Sourcepub fn resolve(
&self,
root_deps: &[PluginDependency],
) -> Result<HashMap<String, SemVer>, ResolveError>
pub fn resolve( &self, root_deps: &[PluginDependency], ) -> Result<HashMap<String, SemVer>, ResolveError>
Resolve the given root dependencies to a concrete HashMap<plugin_id, version>.
§Errors
ResolveError::NotFound— a dependency names an unregistered plugin.ResolveError::Conflict— two constraints for the same plugin have no common satisfying version.ResolveError::CircularDependency— the dependency graph has a cycle.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DependencyResolver
impl RefUnwindSafe for DependencyResolver
impl Send for DependencyResolver
impl Sync for DependencyResolver
impl Unpin for DependencyResolver
impl UnsafeUnpin for DependencyResolver
impl UnwindSafe for DependencyResolver
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
Mutably borrows from an owned value. Read more
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>
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 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>
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