1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use cargo_metadata::DependencyKind;
use petgraph::prelude::*;
mod build;
mod graph;
mod print;
mod select;
pub use crate::petgraph_support::dot::DotWrite;
pub use graph::*;
pub use print::*;
pub use select::*;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum DependencyDirection {
Forward,
Reverse,
}
impl DependencyDirection {
pub fn opposite(&self) -> Self {
match self {
DependencyDirection::Forward => DependencyDirection::Reverse,
DependencyDirection::Reverse => DependencyDirection::Forward,
}
}
fn to_direction(self) -> Direction {
match self {
DependencyDirection::Forward => Direction::Outgoing,
DependencyDirection::Reverse => Direction::Incoming,
}
}
}
fn kind_str(kind: DependencyKind) -> &'static str {
match kind {
DependencyKind::Normal => "normal",
DependencyKind::Build => "build",
DependencyKind::Development => "dev",
_ => "unknown",
}
}