💾 Archived View for 80h.dev › projects › gemserv › files › src › status.rs.gemini captured on 2022-06-12 at 00:48:48. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-03-01)

-=-=-=-=-=-=-

01 use std::fmt;

02

03 #[allow(dead_code)]

04 #[repr(u8)]

05 #[derive(Debug, Copy, Clone)]

06 pub enum Status {

07 Input = 10,

08 Success = 20,

09 SuccessEndOfSession = 21,

10 RedirectTemporary = 30,

11 RedirectPermanent = 31,

12 TemporaryFailure = 40,

13 ServerUnavailable = 41,

14 CGIError = 42,

15 ProxyError = 43,

16 SlowDown = 44,

17 PermanentFailure = 50,

18 NotFound = 51,

19 Gone = 52,

20 ProxyRequestRefused = 53,

21 BadRequest = 59,

22 ClientCertificateRequired = 60,

23 TransientCertificateRequested = 61,

24 AuthorisedCertificateRequired = 62,

25 CertificateNotAccepted = 63,

26 FutureCertificateRejected = 64,

27 ExpiredCertificateRejected = 65,

28 }

29

30 impl Status {

31 pub fn to_str(&self) -> &str {

32 let meta = match self {

33 Status::Input => "Input",

34 Status::Success => "Success",

35 Status::SuccessEndOfSession => "Success End Of Session",

36 Status::RedirectTemporary => "Redirect Temporary",

37 Status::RedirectPermanent => "Redirect Permanent",

38 Status::TemporaryFailure => "Temporary Failure",

39 Status::ServerUnavailable => "Server Unavailable",

40 Status::CGIError => "CGI Error!",

41 Status::ProxyError => "Proxy Error!",

42 Status::SlowDown => "Slow Down!",

43 Status::PermanentFailure => "Permanent Failure",

44 Status::NotFound => "Not Found!",

45 Status::Gone => "Gone!",

46 Status::ProxyRequestRefused => "Proxy Requet Refused",

47 Status::BadRequest => "Bad Request!",

48 Status::ClientCertificateRequired => "Client Certificate Required",

49 Status::TransientCertificateRequested => "Transient Certificate Requested",

50 Status::AuthorisedCertificateRequired => "Authorised Certificate Required",

51 Status::CertificateNotAccepted => "Certificate Not Accepted",

52 Status::FutureCertificateRejected => "Future Certificate Rejected",

53 Status::ExpiredCertificateRejected => "Expired Certificate Rejected",

54 };

55 return meta;

56 }

57 }

58

59 impl fmt::Display for Status {

60 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

61 write!(f, "{:?}", self)

62 }

63 }