diff src/items.rs @ 60:05cc2c27334f

The Big Refactor: clean up docs and exports. - Brings the most important symbols in the library to the root with `pub use` statements. - Expands and updates documentation. - Rearranges things extensively to make the external interface nicer and make the structure easier to understand. - Renames a few things (e.g. `Result`).
author Paul Fisher <paul@pfish.zone>
date Wed, 21 May 2025 19:00:51 -0400
parents 3f4a77aa88be
children d83623951070
line wrap: on
line diff
--- a/src/items.rs	Wed May 21 00:27:18 2025 -0400
+++ b/src/items.rs	Wed May 21 19:00:51 2025 -0400
@@ -1,37 +1,43 @@
+//! Things that can be gotten with the `pam_get_item` function.
+
 use crate::constants::InvalidEnum;
 use num_derive::FromPrimitive;
 use num_traits::FromPrimitive;
 use std::ffi::{c_int, CStr};
 
+/// Enum identifying what a `pam_get_item` return is.
+///
+/// Generally, you shouldn’t have to worry about this, and instead
+/// just use the various [Item] implementations.
 #[derive(FromPrimitive)]
 #[repr(i32)]
 #[non_exhaustive] // because C could give us anything!
 pub enum ItemType {
-    /// The service name
+    /// The PAM service name.
     Service = 1,
-    /// The user name
+    /// The user's login name.
     User = 2,
-    /// The tty name
+    /// The TTY name.
     Tty = 3,
-    /// The remote host name
+    /// The remote host (if applicable).
     RemoteHost = 4,
-    /// The pam_conv structure
+    /// The [crate::Conversation] structure.
     Conversation = 5,
-    /// The authentication token (password)
+    /// The authentication token (password).
     AuthTok = 6,
-    /// The old authentication token
+    /// The old authentication token (when changing passwords).
     OldAuthTok = 7,
-    /// The remote user name
+    /// The remote user's name.
     RemoteUser = 8,
-    /// the prompt for getting a username
+    /// The prompt shown when requesting a username.
     UserPrompt = 9,
-    /// app supplied function to override failure delays
+    /// App-supplied function to override failure delays.
     FailDelay = 10,
-    /// X :display name
+    /// X display name.
     XDisplay = 11,
-    /// X :server authentication data
+    /// X server authentication data.
     XAuthData = 12,
-    /// The type for pam_get_authtok
+    /// The type of `pam_get_authtok`.
     AuthTokType = 13,
 }
 
@@ -48,7 +54,7 @@
     }
 }
 
-/// A type that can be requested by [crate::Handle::get_item].
+/// A type that can be requested by [crate::PamHandle::get_item].
 pub trait Item {
     /// The `repr(C)` type that is returned (by pointer) by the underlying `pam_get_item` function.
     type Raw;
@@ -69,7 +75,8 @@
 
 macro_rules! cstr_item {
     ($name:ident) => {
-        ///A `CStr`-based item from a PAM conversation.
+        #[doc = concat!("The [ItemType::", stringify!($name), "]")]
+        #[doc = " item, represented as a [CStr]."]
         #[derive(Debug)]
         pub struct $name<'s>(pub &'s CStr);
 
@@ -98,11 +105,12 @@
     };
 }
 
+// Conversation is not included here since it's special.
+
 cstr_item!(Service);
 cstr_item!(User);
 cstr_item!(Tty);
 cstr_item!(RemoteHost);
-// Conversation is not included here since it's special.
 cstr_item!(AuthTok);
 cstr_item!(OldAuthTok);
 cstr_item!(RemoteUser);