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
58
59
60
61
62
63
64
65
use fmt;
/// The Apache TinkerPop `Direction` token: which end(s) of an edge a step walks to.
///
/// Used by `to_direction()`/`to_e()`/`to_v()` (Gremlin `to(Direction, ..)`, `toE(..)`,
/// `toV(..)`): `to_direction(Direction::Out, ..)` is `out(..)`, `Direction::In` is `in_(..)`,
/// `Direction::Both` is `both(..)`. Gremlin's aliases `Direction.from` and `Direction.to` are
/// `Direction::Out` and `Direction::In`.
///
/// In the Rhai DSL: `Direction.OUT` / `Direction.IN` / `Direction.BOTH` / `Direction.from` /
/// `Direction.to` (or `Direction::OUT` ...).
///
/// ```rust
/// use graphersal::prelude::*;
///
/// let graph = GraphSource::tinkerpop_modern();
/// let lock = graph.read();
/// let names = lock
/// .traversal()
/// .v("1")
/// .to_direction(Direction::Out, "knows")
/// .values("name")
/// .to_list()
/// .unwrap();
/// assert_eq!(names.len(), 2);
/// assert_eq!(Direction::Out.to_string(), "OUT");
/// ```
///
/// Name clash: `petgraph::Direction` has the same name. Code that glob-imports
/// `graphersal::prelude::*` and also needs petgraph's type imports it explicitly (an explicit
/// import shadows the glob one) or uses the full path `graphersal::prelude::Direction`.
///
/// Closed set, so deliberately not `#[non_exhaustive]`: a directed edge has exactly two ends, plus
/// "either".