summaryrefslogtreecommitdiff
path: root/src/response.rs
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2026-03-05 00:50:04 -0500
committerJohn Turner <jturner.usa@gmail.com>2026-03-05 00:50:04 -0500
commit583a62c4a2ac6137134d50f70ff8ad546ac4b2a1 (patch)
tree5012b889f697d272586e32b406b587e82a65c217 /src/response.rs
parentd7a1ffd41201fdbac858156a8200a8ec5a2dbb76 (diff)
downloadhttpd-583a62c4a2ac6137134d50f70ff8ad546ac4b2a1.tar.gz
impl EnumStr and FromRepr for Response codes
Diffstat (limited to 'src/response.rs')
-rw-r--r--src/response.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/response.rs b/src/response.rs
index fa1a294..68189fb 100644
--- a/src/response.rs
+++ b/src/response.rs
@@ -9,21 +9,24 @@ use tokio::{
io::{self, AsyncWrite, AsyncWriteExt},
};
-use strum::Display;
+use strum::{Display, EnumString, FromRepr};
use builder::Builder;
#[allow(unreachable_patterns)]
-#[derive(Debug, Clone, Copy, Display)]
+#[derive(Debug, Clone, Copy, Display, EnumString, FromRepr)]
pub enum Status {
- #[strum(to_string = "200 OK")]
- Ok,
+ #[strum(to_string = "200 OK", serialize = "OK")]
+ Ok = 200,
- #[strum(to_string = "404 Not Found")]
- NotFound,
+ #[strum(to_string = "404 Not Found", serialize = "Not Found")]
+ NotFound = 404,
- #[strum(to_string = "500 Internal Server Error")]
- InternalServerError,
+ #[strum(
+ to_string = "500 Internal Server Error",
+ serialize = "Internal ServerError"
+ )]
+ InternalServerError = 500,
}
#[derive(Debug)]