1use crate::acl::HttpRequestMethod;
4use std::net::{IpAddr, SocketAddr};
5use std::ops::RangeInclusive;
6
7use thiserror::Error;
8
9#[non_exhaustive]
11#[derive(Clone, Debug, Eq, Hash, PartialEq, Error)]
12pub enum AddError {
13 #[error("The HTTP method `{0:?}` is already allowed.")]
15 AlreadyAllowedMethod(HttpRequestMethod),
16 #[error("The HTTP method `{0:?}` is already denied.")]
18 AlreadyDeniedMethod(HttpRequestMethod),
19 #[error("The host `{0}` is already allowed.")]
21 AlreadyAllowedHost(String),
22 #[error("The host `{0}` is already denied.")]
24 AlreadyDeniedHost(String),
25 #[error("The port range `{0:?}` is already allowed.")]
27 AlreadyAllowedPortRange(RangeInclusive<u16>),
28 #[error("The port range `{0:?}` is already denied.")]
30 AlreadyDeniedPortRange(RangeInclusive<u16>),
31 #[error("The IP range `{0:?}` is already allowed.")]
33 AlreadyAllowedIpRange(RangeInclusive<IpAddr>),
34 #[error("The IP range `{0:?}` is already denied.")]
36 AlreadyDeniedIpRange(RangeInclusive<IpAddr>),
37 #[error("The header `{0}` is already allowed.")]
39 AlreadyAllowedHeader(String, Option<String>),
40 #[error("The header `{0}` is already denied.")]
42 AlreadyDeniedHeader(String, Option<String>),
43 #[error("The URL path `{0}` is already allowed.")]
45 AlreadyAllowedUrlPath(String),
46 #[error("The URL path `{0}` is already denied.")]
48 AlreadyDeniedUrlPath(String),
49 #[error("The static DNS mapping for `{0}`-`{1}` is already present.")]
51 AlreadyPresentStaticDnsMapping(String, SocketAddr),
52 #[error("The entity `{0}` is not allowed or denied because it is invalid.")]
54 InvalidEntity(String),
55 #[error("The entity `{0}` is not unique.")]
57 NotUnique(String),
58 #[error("The entity `{0}` overlaps with another.")]
60 Overlaps(String),
61 #[error("The entity `{0}` is both allowed and denied.")]
63 BothAllowedAndDenied(String),
64 #[error("An error occurred: `{0}`")]
66 Error(String),
67}