http_cache/
error.rs

1use std::fmt;
2
3/// Generic error type for the `HttpCache` middleware.
4pub type BoxError = Box<dyn std::error::Error + Send + Sync>;
5
6/// A `Result` typedef to use with the [`BoxError`] type
7pub type Result<T> = std::result::Result<T, BoxError>;
8
9/// Error type for unknown http versions
10#[derive(Debug, Default, Copy, Clone)]
11pub struct BadVersion;
12
13impl fmt::Display for BadVersion {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        f.pad("Unknown HTTP version")
16    }
17}
18
19impl std::error::Error for BadVersion {}
20
21/// Error type for bad header values
22#[derive(Debug, Default, Copy, Clone)]
23pub struct BadHeader;
24
25impl fmt::Display for BadHeader {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        f.pad("Error parsing header value")
28    }
29}
30
31impl std::error::Error for BadHeader {}