diff src/constants.rs @ 131:a632a8874131

Get all the Linux-PAM functions into libpam-sys, and get tests right.
author Paul Fisher <paul@pfish.zone>
date Wed, 02 Jul 2025 02:24:21 -0400
parents 80c07e5ab22f
children efbc235f01d3
line wrap: on
line diff
--- a/src/constants.rs	Tue Jul 01 06:11:43 2025 -0400
+++ b/src/constants.rs	Wed Jul 02 02:24:21 2025 -0400
@@ -6,12 +6,12 @@
 
 use crate::{linklist, man7, manbsd, xsso};
 use bitflags::bitflags;
-use std::ffi::c_int;
 use num_enum::{IntoPrimitive, TryFromPrimitive};
 use std::error::Error;
+use std::ffi::c_int;
+use std::fmt;
 use std::fmt::{Display, Formatter};
 use std::result::Result as StdResult;
-use std::fmt;
 
 /// Values for constants not provided by certain PAM implementations.
 ///
@@ -32,7 +32,6 @@
         (@expand $({ $(#[$m:meta])* } $i:item)+) => {$($(#[$m])* $i)+};
     }
 
-
     define!(
         /// A fictitious constant for testing purposes.
         #[cfg(not(feature = "link"))]
@@ -56,7 +55,6 @@
         PAM_CONV_AGAIN = 517;
         PAM_INCOMPLETE = 518;
     );
-
 }
 
 bitflags! {
@@ -204,7 +202,7 @@
 
     /// A basic Display implementation for if we don't link against PAM.
     fn fmt_internal(self, f: &mut Formatter<'_>) -> fmt::Result {
-        let n : c_int = self.into();
+        let n: c_int = self.into();
         write!(f, "PAM error: {self:?} ({n})")
     }
 }
@@ -212,8 +210,8 @@
 /// Gets a string version of an error message.
 #[cfg(feature = "link")]
 pub fn strerror(code: c_int) -> Option<&'static str> {
+    use std::ffi::CStr;
     use std::ptr;
-    use std::ffi::CStr;
     // SAFETY: PAM impls don't care about the PAM handle and always return
     // static strings.
     let strerror = unsafe { libpam_sys::pam_strerror(ptr::null(), code as c_int) };