simbld_http/responses/
service.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use crate::helpers::{from_u16_helper::FromU16, to_u16_helper::ToU16};
use num_enum::{IntoPrimitive, TryFromPrimitive};
use strum::EnumProperty;
use strum_macros::{Display, EnumIter, EnumProperty};

#[derive(Display, IntoPrimitive, TryFromPrimitive, EnumProperty, EnumIter, Debug, Copy, Clone)]
#[repr(u16)]

pub enum ResponsesServiceCodes {
  #[strum(props(
    Description = "An error occurred while reading the response or data from the server"
  ))]
  ReadingError = 611,
  #[strum(props(
    Description = "A connection issue occurred, preventing successful communication with the server"
  ))]
  ConnectionError = 612,
  #[strum(props(
    Description = "The reading operation exceeded the allowed time limit, resulting in a timeout"
  ))]
  ReadingTimeExpired = 613,
  #[strum(props(
    Description = "The SSL handshake failed, potentially due to invalid certificates or incompatible protocols"
  ))]
  SSLHandshakeFailed = 614,
  #[strum(props(Description = "A generic error occurred while reading the response or data"))]
  AnotherReadingError = 615,
  #[strum(props(
    Description = "An anomaly was detected in the Full Body Analyzer process, likely due to unexpected input"
  ))]
  FBAAnomaly = 616,
  #[strum(props(
    Description = "An error in the implementation or logic caused the request to fail"
  ))]
  CodingError = 617,
  #[strum(props(
    Description = "The server issued a redirect response but did not provide a valid redirect URL"
  ))]
  RedirectWithoutRedirectURL = 618,
  #[strum(props(
    Description = "The DNS lookup for the specified domain failed, indicating a potential network or configuration issue"
  ))]
  DNSLookupFailed = 680,
  #[strum(props(
    Description = "The provided URL is syntactically incorrect and cannot be processed"
  ))]
  SyntacticallyIncorrectURL = 690,
  #[strum(props(
    Description = "The connection to the server was lost unexpectedly during communication"
  ))]
  LostConnection = 691,
  #[strum(props(
    Description = "The operation timed out while attempting to write data to the server"
  ))]
  WriteTimeout = 692,
  #[strum(props(
    Description = "The requested operation failed during a selection or matching process"
  ))]
  SelectionFailed = 693,
  #[strum(props(
    Description = "An error occurred while attempting to write data to the destination"
  ))]
  WriteError = 694,
  #[strum(props(
    Description = "A block header was incomplete or malformed, preventing further processing"
  ))]
  IncompleteBlockHeader = 695,
  #[strum(props(
    Description = "An unexpected error occurred, often indicative of an unforeseen issue or bug"
  ))]
  UnexpectedError = 699,
}

impl ToU16 for ResponsesServiceCodes {
  fn to_u16(self) -> u16 {
    self.into() // Conversion`Into<u16>`
  }
}

impl FromU16 for ResponsesServiceCodes {
  fn from_u16(code: u16) -> Option<Self> {
    Self::try_from(code).ok() // Conversion`TryFrom<u16>`
  }
}

impl Into<(u16, &'static str)> for ResponsesServiceCodes {
  fn into(self) -> (u16, &'static str) {
    let code: u16 = self.to_u16();
    let description = self.get_str("Description").unwrap_or("No description");
    (code, description) // Tuple
  }
}