Skip to main content

alchemy_styles/stretch/
mod.rs

1//! This module is included while awaiting an upstream merge in stretch proper.
2//! You should not rely on it, and consider it an implementation detail.
3
4pub mod geometry;
5pub mod node;
6pub mod number;
7pub mod result;
8pub mod style;
9
10mod algo;
11mod id;
12
13use core::any::Any;
14
15#[derive(Debug)]
16pub enum Error {
17    InvalidNode(node::Node),
18    Measure(Box<Any>),
19}
20
21impl std::fmt::Display for Error {
22    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
23        match *self {
24            Error::InvalidNode(ref node) => write!(f, "Invalid node {:?}", node),
25            Error::Measure(_) => write!(f, "Error during measurement"),
26        }
27    }
28}
29
30impl std::error::Error for Error {
31    fn description(&self) -> &str {
32        match *self {
33            Error::InvalidNode(_) => "The node is not part of the stretch instance",
34            Error::Measure(_) => "Error occurred inside a measurement function",
35        }
36    }
37}