Struct hua_core::dependency::DependencyGraph  
source · [−]pub struct DependencyGraph<'a> { /* private fields */ }Expand description
A directed acyclic graph for dependency resolution.
Example
use std::collections::BTreeSet;
use semver::VersionReq;
use hua_core::dependency::{DependencyGraph, Requirement};
use hua_core::store::MemoryStore;
let store = MemoryStore::init()?;
let mut graph = DependencyGraph::new();
let first_req = Requirement::new("first".to_owned(), VersionReq::parse(">0.1.0")?, BTreeSet::new());
let second_req = Requirement::new("second".to_owned(), VersionReq::parse(">1.1.0")?, BTreeSet::new());
let requirements = [&first_req, &second_req];
graph.resolve(requirements, &store)?;
assert!(!graph.is_resolved());Implementations
sourceimpl<'a> DependencyGraph<'a>
 
impl<'a> DependencyGraph<'a>
sourcepub fn new() -> Self
 
pub fn new() -> Self
Creates a new DependencyGraph.
Example
use hua_core::dependency::DependencyGraph;
let graph = DependencyGraph::new();sourcepub fn resolve<S, B: ReadBackend>(
    &mut self,
    requirements: impl IntoIterator<Item = &'a Requirement>,
    store: &'a Store<S, B>
) -> Result<(), DependencyError>
 
pub fn resolve<S, B: ReadBackend>(
    &mut self,
    requirements: impl IntoIterator<Item = &'a Requirement>,
    store: &'a Store<S, B>
) -> Result<(), DependencyError>
Resolves multiple Requirement with the given Store.
Example
use std::collections::BTreeSet;
use semver::VersionReq;
use hua_core::dependency::{DependencyGraph, Requirement};
use hua_core::store::MemoryStore;
let store = MemoryStore::init()?;
let mut graph = DependencyGraph::new();
let first_req = Requirement::new("first".to_owned(), VersionReq::parse(">0.1.0")?, BTreeSet::new());
let second_req = Requirement::new("second".to_owned(), VersionReq::parse(">1.1.0")?, BTreeSet::new());
let requirements = [&first_req, &second_req];
graph.resolve(requirements, &store)?;
assert!(!graph.is_resolved());sourcepub fn unresolved_requirements(&self) -> impl Iterator<Item = &Requirement>
 
pub fn unresolved_requirements(&self) -> impl Iterator<Item = &Requirement>
Returns all Requirement that are still unresolved.
sourcepub fn resolved_packages(&self) -> impl Iterator<Item = PackageId> + '_
 
pub fn resolved_packages(&self) -> impl Iterator<Item = PackageId> + '_
Returns all PackageId that are resolved.
sourcepub fn is_resolved(&self) -> bool
 
pub fn is_resolved(&self) -> bool
Checks if the DependencyGraph is resolved.
Trait Implementations
sourceimpl<'a> Clone for DependencyGraph<'a>
 
impl<'a> Clone for DependencyGraph<'a>
sourcefn clone(&self) -> DependencyGraph<'a>
 
fn clone(&self) -> DependencyGraph<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<'a> Debug for DependencyGraph<'a>
 
impl<'a> Debug for DependencyGraph<'a>
sourceimpl<'a> Default for DependencyGraph<'a>
 
impl<'a> Default for DependencyGraph<'a>
sourcefn default() -> DependencyGraph<'a>
 
fn default() -> DependencyGraph<'a>
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl<'a> RefUnwindSafe for DependencyGraph<'a>
impl<'a> Send for DependencyGraph<'a>
impl<'a> Sync for DependencyGraph<'a>
impl<'a> Unpin for DependencyGraph<'a>
impl<'a> UnwindSafe for DependencyGraph<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
    T: ?Sized, 
 
impl<T> BorrowMut<T> for T where
    T: ?Sized, 
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
 
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
 
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
    S: Into<Dispatch>, 
 
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
    S: Into<Dispatch>, 
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
 
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more