doxing_emulator/
messages.rs1use std::fmt;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum BotError {
8 DoxerIdentificationFailed,
10 DoxeeIdentificationFailed,
12 InvalidOrigin,
14 NotUserId,
16 Incomprehensible,
18}
19
20impl BotError {
21 #[must_use]
23 pub const fn as_str(self) -> &'static str {
24 match self {
25 Self::DoxerIdentificationFailed => {
26 include_str!("messages/doxer-identification-failed.html")
27 }
28 Self::DoxeeIdentificationFailed => {
29 include_str!("messages/doxee-identification-failed.html")
30 }
31 Self::InvalidOrigin => include_str!("messages/invalid-origin.html"),
32 Self::NotUserId => include_str!("messages/not-user-id.html"),
33 Self::Incomprehensible => include_str!("messages/incomprehensible.html"),
34 }
35 }
36}
37
38impl AsRef<str> for BotError {
39 fn as_ref(&self) -> &str {
40 self.as_str()
41 }
42}
43
44impl From<BotError> for &'static str {
45 fn from(error: BotError) -> Self {
46 error.as_str()
47 }
48}
49
50impl From<BotError> for String {
51 fn from(error: BotError) -> Self {
52 error.as_str().to_owned()
53 }
54}
55
56impl fmt::Display for BotError {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 f.write_str(self.as_str())
59 }
60}