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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
use simplecss;
use svgtypes;
use svgtypes::xmlparser::{
self,
ErrorPos,
};
#[derive(Fail, Debug)]
pub enum Error {
#[fail(display = "the element must have an id")]
ElementMustHaveAnId,
#[fail(display = "element crosslink")]
ElementCrosslink,
#[fail(display = "the document does not have an SVG element")]
NoSvgElement,
#[fail(display = "the document does not have any nodes")]
EmptyDocument,
#[fail(display = "unsupported CSS at {}", _0)]
UnsupportedCSS(ErrorPos),
#[fail(display = "invalid CSS at {}", _0)]
InvalidCSS(ErrorPos),
#[fail(display = "unsupported ENTITY data at {}", _0)]
UnsupportedEntity(ErrorPos),
#[fail(display = "valid FuncIRI(#{}) with fallback value is not supported", _0)]
UnsupportedPaintFallback(String),
#[fail(display = "the 'use' element with a broken filter attribute('#{}') is not supported", _0)]
BrokenFuncIri(String),
#[fail(display = "attribute '{}' is missing in the '{}' element", _0, _1)]
MissingAttribute(String, String),
#[fail(display = "{}", _0)]
SvgTypesError(svgtypes::Error),
#[fail(display = "{}", _0)]
XmlError(xmlparser::Error),
#[fail(display = "{:?}", _0)]
CssError(simplecss::Error),
}
impl From<xmlparser::Error> for Error {
fn from(value: xmlparser::Error) -> Error {
Error::XmlError(value)
}
}
impl From<svgtypes::Error> for Error {
fn from(value: svgtypes::Error) -> Error {
Error::SvgTypesError(value)
}
}
impl From<simplecss::Error> for Error {
fn from(value: simplecss::Error) -> Error {
Error::CssError(value)
}
}
pub(crate) type Result<T> = ::std::result::Result<T, Error>;