boa_engine/vm/flowgraph/edge.rs
1use crate::vm::flowgraph::Color;
2
3/// Represents the edge (connection) style.
4#[derive(Debug, Clone, Copy)]
5pub enum EdgeStyle {
6 /// Represents a solid line.
7 Line,
8 /// Represents a dotted line.
9 Dotted,
10 /// Represents a dashed line.
11 Dashed,
12}
13
14/// Represents the edge type.
15#[derive(Debug, Clone, Copy)]
16pub enum EdgeType {
17 /// Represents no decoration on the edge line.
18 None,
19 /// Represents arrow edge type.
20 Arrow,
21}
22
23/// Represents an edge/connection in the flowgraph.
24#[derive(Debug, Clone)]
25pub struct Edge {
26 /// The location of the source node.
27 pub(super) from: usize,
28 /// The location of the destination node.
29 pub(super) to: usize,
30 /// The label on top of the edge.
31 pub(super) label: Option<Box<str>>,
32 /// The color of the line.
33 pub(super) color: Color,
34 /// The style of the line.
35 pub(super) style: EdgeStyle,
36 /// The type of the line.
37 pub(super) type_: EdgeType,
38}
39
40impl Edge {
41 /// Construct a new edge.
42 pub(super) const fn new(
43 from: usize,
44 to: usize,
45 label: Option<Box<str>>,
46 color: Color,
47 style: EdgeStyle,
48 ) -> Self {
49 Self {
50 from,
51 to,
52 label,
53 color,
54 style,
55 type_: EdgeType::Arrow,
56 }
57 }
58
59 /// Set the type of the edge.
60 #[inline]
61 pub fn set_type(&mut self, type_: EdgeType) {
62 self.type_ = type_;
63 }
64}