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
use core::fmt::{self, Display, Formatter};
#[cfg(feature = "std")]
use std::error::Error;
#[cfg(feature = "std")]
use std::io;
#[derive(Debug)]
pub enum HTMLMinifierError {
CSSError(&'static str),
#[cfg(feature = "std")]
IOError(io::Error),
}
#[cfg(feature = "std")]
impl From<io::Error> for HTMLMinifierError {
#[inline]
fn from(error: io::Error) -> Self {
HTMLMinifierError::IOError(error)
}
}
impl Display for HTMLMinifierError {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
match self {
HTMLMinifierError::CSSError(error) => Display::fmt(error, f),
#[cfg(feature = "std")]
HTMLMinifierError::IOError(error) => Display::fmt(error, f),
}
}
}
#[cfg(feature = "std")]
impl Error for HTMLMinifierError {}