firestore_structured_query/
error.rs

1/// A result type for this crate.
2pub type Result<T> = std::result::Result<T, Error>;
3
4/// An error that can occur when working with this crate.
5#[derive(Debug)]
6pub struct Error {
7    source: Box<dyn std::error::Error + Send + Sync>,
8}
9
10impl Error {
11    /// Create a new error from a source error.
12    pub fn new<E>(source: E) -> Self
13    where
14        E: Into<Box<dyn std::error::Error + Send + Sync>>,
15    {
16        Self::from(source.into())
17    }
18}
19
20impl std::convert::From<Box<dyn std::error::Error + Send + Sync>> for Error {
21    fn from(source: Box<dyn std::error::Error + Send + Sync>) -> Self {
22        Self { source }
23    }
24}
25
26impl std::error::Error for Error {
27    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
28        Some(&*self.source)
29    }
30}
31
32impl std::fmt::Display for Error {
33    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34        self.source.fmt(f)
35    }
36}