pub struct DependencyGraph { /* private fields */ }Expand description
Directed acyclic graph of package dependencies.
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn new(packages: Vec<Package>) -> Result<Self>
pub fn new(packages: Vec<Package>) -> Result<Self>
Creates a new dependency graph from a list of packages.
§Errors
Returns an error if circular dependencies are detected.
Sourcepub fn get_package(&self, name: &str) -> Option<&Package>
pub fn get_package(&self, name: &str) -> Option<&Package>
Retrieves a package by name.
Sourcepub fn topological_order(&self) -> Vec<String>
pub fn topological_order(&self) -> Vec<String>
Returns packages in topological order (dependencies before dependents).
This is cached during graph construction for fast access.
Sourcepub fn dependency_levels(&self) -> Vec<Vec<String>>
pub fn dependency_levels(&self) -> Vec<Vec<String>>
Returns dependency levels for parallel execution.
Each level contains packages that can be executed in parallel.
Sourcepub fn dependencies(&self, package_name: &str) -> Result<Vec<String>>
pub fn dependencies(&self, package_name: &str) -> Result<Vec<String>>
Returns direct dependencies of a package.
§Errors
Returns an error if the package is not found in the graph.
Sourcepub fn dependents(&self, package_name: &str) -> Result<Vec<String>>
pub fn dependents(&self, package_name: &str) -> Result<Vec<String>>
Returns direct dependents of a package (packages that depend on it).
§Errors
Returns an error if the package is not found in the graph.
Sourcepub fn all_dependents(&self, package_name: &str) -> Result<HashSet<String>>
pub fn all_dependents(&self, package_name: &str) -> Result<HashSet<String>>
Returns all transitive dependents of a package.
This includes both direct and indirect dependents (packages that depend on packages that depend on this package, etc.).
§Errors
Returns an error if the package is not found in the graph.
Sourcepub fn affected_packages(
&self,
changed_packages: &[String],
) -> Result<HashSet<String>>
pub fn affected_packages( &self, changed_packages: &[String], ) -> Result<HashSet<String>>
Returns all packages affected by changes to the given packages.
This includes the changed packages themselves and all their transitive dependents.
§Errors
Returns an error if any of the changed packages are not found in the graph.
Sourcepub fn all_packages(&self) -> Vec<&Package>
pub fn all_packages(&self) -> Vec<&Package>
Returns all packages in the graph.
Sourcepub fn save_to_file(&self, path: impl AsRef<Path>) -> Result<()>
pub fn save_to_file(&self, path: impl AsRef<Path>) -> Result<()>
Serializes the graph to a file for fast loading.
Sourcepub fn load_from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn load_from_file(path: impl AsRef<Path>) -> Result<Self>
Loads a graph from a previously saved file.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DependencyGraph
impl RefUnwindSafe for DependencyGraph
impl Send for DependencyGraph
impl Sync for DependencyGraph
impl Unpin for DependencyGraph
impl UnsafeUnpin for DependencyGraph
impl UnwindSafe for DependencyGraph
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