diff src/constants.rs @ 63:a7aa5ca0d00d

Move MessageStyle to conv, the only place it is used.
author Paul Fisher <paul@pfish.zone>
date Wed, 21 May 2025 23:19:43 -0400
parents 05cc2c27334f
children bbe84835d6db
line wrap: on
line diff
--- a/src/constants.rs	Wed May 21 23:10:09 2025 -0400
+++ b/src/constants.rs	Wed May 21 23:19:43 2025 -0400
@@ -35,38 +35,6 @@
     }
 }
 
-/// Styles of message that are shown to the user.
-#[derive(Debug, PartialEq, FromPrimitive)]
-#[non_exhaustive] // non-exhaustive because C might give us back anything!
-pub enum MessageStyle {
-    /// Requests information from the user; will be masked when typing.
-    PromptEchoOff = 1,
-    /// Requests information from the user; will not be masked.
-    PromptEchoOn = 2,
-    /// An error message.
-    ErrorMsg = 3,
-    /// An informational message.
-    TextInfo = 4,
-    /// Yes/No/Maybe conditionals. Linux-PAM specific.
-    RadioType = 5,
-    /// For server–client non-human interaction.
-    /// NOT part of the X/Open PAM specification.
-    BinaryPrompt = 7,
-}
-
-impl TryFrom<c_int> for MessageStyle {
-    type Error = InvalidEnum<Self>;
-    fn try_from(value: c_int) -> std::result::Result<Self, Self::Error> {
-        Self::from_i32(value).ok_or(value.into())
-    }
-}
-
-impl From<MessageStyle> for c_int {
-    fn from(val: MessageStyle) -> Self {
-        val as Self
-    }
-}
-
 /// The Linux-PAM error return values. Success is an Ok [Result].
 ///
 /// Most abbreviations (except `AuthTok` and `Max`) are now full words.
@@ -200,12 +168,12 @@
 
     #[test]
     fn test_enums() {
-        assert_eq!(Ok(MessageStyle::ErrorMsg), 3.try_into());
+        assert_eq!(Ok(ErrorCode::ServiceError), 3.try_into());
         assert_eq!(Err(InvalidEnum::from(999)), ErrorCode::try_from(999));
         assert_eq!(Ok(()), ErrorCode::result_from(0));
         assert_eq!(Err(ErrorCode::Abort), ErrorCode::result_from(26));
         assert_eq!(Err(ErrorCode::SystemError), ErrorCode::result_from(423));
-        assert!(InvalidEnum::<MessageStyle>(33, PhantomData)
+        assert!(InvalidEnum::<ErrorCode>(33, PhantomData)
             .to_string()
             .starts_with("33 is not a valid "));
     }