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
pub type Result<T, E = GraphOperationError> = std::result::Result<T, E>;
#[derive(thiserror::Error, Debug, Eq, PartialEq)]
pub enum GraphOperationError {
#[error("this vertex_id already exists in the graph")]
VertexAlreadyExists,
#[error("this vertex_id does not exist in the graph")]
VertexDoesNotExist,
#[error("unable to find edge in graph between two vertices")]
EdgeDoesNotExist,
}
#[derive(thiserror::Error, Debug, Eq, PartialEq)]
pub enum ParseGraphError {
#[error("incorrect vertex definition at line {0}")]
VertexDefinition(usize),
#[error("incorrect edge definition at line {0}")]
EdgeDefinition(usize),
#[error("vertex with index {0} already defined, check line {1}")]
VertexAlreadyDefined(usize, usize),
#[error("failed to join vertices with ids {0}, {1} because they are not defined at line {2}")]
VerticesNotDefined(usize, usize, usize),
#[error("failed to parse index of the vertex or edge at line {0}")]
ParseInt(usize),
#[error("failed to parse label data of the vertex or edge at line {0}")]
ParseLabel(usize),
#[error("some graph operation failed: {0} at line {1}")]
GraphError(GraphOperationError, usize),
}