universal_inserter/
error.rs

1use std::error::Error;
2use std::fmt;
3
4#[derive(Debug)]
5pub struct InserterError<E: Error> {
6    source: E,
7}
8
9impl<E: Error> InserterError<E> {
10    pub const fn new(source: E) -> Self {
11        Self { source }
12    }
13
14    pub fn into_inner(self) -> E {
15        self.source
16    }
17}
18
19impl<E: Error> fmt::Display for InserterError<E> {
20    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21        write!(f, "inserter error: {}", self.source)
22    }
23}
24
25impl<E: Error + 'static> Error for InserterError<E> {
26    fn source(&self) -> Option<&(dyn Error + 'static)> {
27        Some(&self.source)
28    }
29}
30
31impl<E: Error> From<E> for InserterError<E> {
32    fn from(source: E) -> Self {
33        Self::new(source)
34    }
35}