diff src/memory.rs @ 64:bbe84835d6db v0.0.5

More organization; add lots of docs. - moves `PamHandle` to its own module, since it will be used by both modules and clients. - adds a ton of documentation to the `PamModule` trait and reorders methods to most-interesting-first. - adds more flag values from pam_modules.h. - other misc cleanup.
author Paul Fisher <paul@pfish.zone>
date Thu, 22 May 2025 01:52:32 -0400
parents 05cc2c27334f
children
line wrap: on
line diff
--- a/src/memory.rs	Wed May 21 23:19:43 2025 -0400
+++ b/src/memory.rs	Thu May 22 01:52:32 2025 -0400
@@ -1,11 +1,11 @@
 //! Utility functions for dealing with memory copying and stuff.
 
-use crate::ErrorCode;
+use crate::constants::{ErrorCode, Result};
 use libc::c_char;
 use std::ffi::{CStr, CString};
 
 /// Safely converts a `&str` option to a `CString` option.
-pub fn option_cstr(prompt: Option<&str>) -> crate::Result<Option<CString>> {
+pub fn option_cstr(prompt: Option<&str>) -> Result<Option<CString>> {
     prompt
         .map(CString::new)
         .transpose()
@@ -22,7 +22,7 @@
 
 /// Creates an owned copy of a string that is returned from a
 /// <code>pam_get_<var>whatever</var></code> function.
-pub fn copy_pam_string(result_ptr: *const c_char) -> crate::Result<String> {
+pub fn copy_pam_string(result_ptr: *const c_char) -> Result<String> {
     // We really shouldn't get a null pointer back here, but if we do, return nothing.
     if result_ptr.is_null() {
         return Ok(String::new());