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(
40 "The IP range `{0:?}` is not a global IP range, and non-global IP ranges are not allowed."
41 )]
42 NonGlobalIpRange(RangeInclusive<IpAddr>),
43 #[error("The header `{0}` is already allowed.")]
45 AlreadyAllowedHeader(String, Option<String>),
46 #[error("The header `{0}` is already denied.")]
48 AlreadyDeniedHeader(String, Option<String>),
49 #[error("The URL path `{0}` is already allowed.")]
51 AlreadyAllowedUrlPath(String),
52 #[error("The URL path `{0}` is already denied.")]
54 AlreadyDeniedUrlPath(String),
55 #[error("The static DNS mapping for `{0}`-`{1}` is already present.")]
57 AlreadyPresentStaticDnsMapping(String, SocketAddr),
58 #[error("The entity `{0}` is not allowed or denied because it is invalid.")]
60 InvalidEntity(String),
61 #[error("The entity `{0}` is not unique.")]
63 NotUnique(String),
64 #[error("The entity `{0}` overlaps with another.")]
66 Overlaps(String),
67 #[error("The entity `{0}` is both allowed and denied.")]
69 BothAllowedAndDenied(String),
70 #[error("An error occurred: `{0}`")]
72 Error(String),
73}