1use std::convert::Infallible;
8
9use http::uri::InvalidUri;
10use snafu::{AsErrorSource, Snafu};
11
12use crate::platform::MaybeSendSync;
13
14pub trait Error: std::error::Error + AsErrorSource + MaybeSendSync + 'static {
16 fn is_retryable(&self) -> bool;
18}
19
20impl Error for Infallible {
21 fn is_retryable(&self) -> bool {
22 false
23 }
24}
25
26#[derive(Debug, Snafu)]
28#[snafu(transparent)]
29pub struct BoxedError {
30 source: Box<dyn Error>,
31}
32
33impl BoxedError {
34 pub fn from_err<E: Error + 'static>(err: E) -> Self {
36 Self {
37 source: Box::new(err),
38 }
39 }
40}
41
42impl Error for BoxedError {
43 fn is_retryable(&self) -> bool {
44 self.source.is_retryable()
45 }
46}
47
48impl Error for InvalidUri {
49 fn is_retryable(&self) -> bool {
50 false
51 }
52}