diff src/conv.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/conv.rs	Wed May 21 00:27:18 2025 -0400
+++ b/src/conv.rs	Wed May 21 19:00:51 2025 -0400
@@ -1,10 +1,12 @@
+//! The [Conversation] struct, for interacting with the user.
+
 use libc::{c_char, c_int};
 use std::ffi::{CStr, CString};
 use std::ptr;
 
 use crate::constants::ErrorCode;
 use crate::constants::MessageStyle;
-use crate::constants::PamResult;
+use crate::constants::Result;
 use crate::items::Item;
 
 #[repr(C)]
@@ -19,6 +21,7 @@
     resp_retcode: libc::c_int, // Unused - always zero
 }
 
+#[doc(hidden)]
 #[repr(C)]
 pub struct Inner {
     conv: extern "C" fn(
@@ -30,30 +33,24 @@
     appdata_ptr: *const libc::c_void,
 }
 
-/// A `Conv`ersation channel with the user.
+/// A communication channel with the user.
 ///
-/// Communication is mediated by the PAM client (the application that invoked
-/// pam).  Messages sent will be relayed to the user by the client, and response
-/// will be relayed back.
-pub struct Conv<'a>(&'a Inner);
+/// Use this to communicate with the user, if needed, beyond the standard
+/// things you can get/set with `get_user`/`get_authtok` and friends.
+/// The PAM client (i.e., the application that is logging in) will present
+/// the messages you send to the user and ask for responses.
+pub struct Conversation<'a>(&'a Inner);
 
-impl Conv<'_> {
-    /// Sends a message to the pam client.
+impl Conversation<'_> {
+    /// Sends a message to the PAM client.
     ///
     /// This will typically result in the user seeing a message or a prompt.
-    /// There are several message styles available:
+    /// For details, see what [MessageStyle]s are available.
     ///
-    /// - PAM_PROMPT_ECHO_OFF
-    /// - PAM_PROMPT_ECHO_ON
-    /// - PAM_ERROR_MSG
-    /// - PAM_TEXT_INFO
-    /// - PAM_RADIO_TYPE
-    /// - PAM_BINARY_PROMPT
-    ///
-    /// Note that the user experience will depend on how the client implements
-    /// these message styles - and not all applications implement all message
-    /// styles.
-    pub fn send(&self, style: MessageStyle, msg: &str) -> PamResult<Option<&CStr>> {
+    /// Note that the user experience will depend on how each style
+    /// is implemented by the client, and that not all clients
+    /// will implement all message styles.
+    pub fn send(&self, style: MessageStyle, msg: &str) -> Result<Option<&CStr>> {
         let mut resp_ptr: *const Response = ptr::null();
         let msg_cstr = CString::new(msg).unwrap();
         let msg = Message {
@@ -74,7 +71,7 @@
     }
 }
 
-impl Item for Conv<'_> {
+impl Item for Conversation<'_> {
     type Raw = Inner;
 
     fn type_id() -> crate::items::ItemType {