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
use crate::graph::NodeHandle;
use crate::node::Name;
use std::any::TypeId;
use std::fmt;
#[derive(Clone, Debug)]
pub enum Error {
InvalidNodeHandle(NodeHandle),
UnknownInput(Name),
UnknownOutput(Name),
Incompatible { input: TypeId, output: TypeId },
Cycle(NodeHandle),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::InvalidNodeHandle(handle) => {
write!(f, "The node handle ({}) is invalid", handle.0)
}
Self::UnknownInput(name) => write!(f, "The input {} does not exist", name),
Self::UnknownOutput(name) => write!(f, "The output {} does not exist", name),
Self::Incompatible { .. } => write!(f, "The input and the output are not compatible"),
Self::Cycle(handle) => write!(f, "The node ({}) depends on itself", handle.0),
}
}
}
pub type Result<T> = std::result::Result<T, Error>;