view libpam-sys/libpam-sys-helpers/src/lib.rs @ 141:a508a69c068a

Remove a lot of Results from functions. Many functions are documented to only return failing Results when given improper inputs or when there is a memory allocation failure (which can be verified by looking at the source). In cases where we know our input is correct, we don't need to check for memory allocation errors for the same reason that Rust doesn't do so when you, e.g., create a new Vec.
author Paul Fisher <paul@pfish.zone>
date Sat, 05 Jul 2025 17:16:56 -0400
parents efbc235f01d3
children
line wrap: on
line source

#![doc = include_str!("../README.md")]
//!
//! ## Current implementation
//!
//! This documentation was built based on the
#![doc = concat!("**", env!("LIBPAMSYS_IMPL"), "** implementation.")]

pub mod constants;
pub mod memory;

/// Information about the PAM implementation you're using right now.
///
/// This module contains constants and values that can be used at build-script,
/// compile, and run time to determine what PAM implementation you're using.
///
/// ## Always available
///
/// [`PamImpl::CURRENT`] will tell you what version of PAM you're using.
/// It can be imported in any Rust code, from build scripts to runtime.
///
/// ## Compile time
///
/// Use [`enable_pam_impl_cfg`] in your `build.rs` to generate custom `#[cfg]`s
/// for conditional compilation based on PAM implementation.
///
/// This will set the current `pam_impl` as well as registering all known
/// PAM implementations with `rustc-check-cfg` to get cfg-checking.
///
/// The names that appear in the `cfg` variables are the same as the values
/// in the [`PamImpl`] enum.
///
/// ```
/// #[cfg(pam_impl = "OpenPam")]
/// fn openpam_specific_func(handle: *const libpam_sys::pam_handle) {
///     let environ = libpam_sys::pam_getenvlist(handle);
///     // ...
///     libpam_sys::openpam_free_envlist()
/// }
///
/// // This will give you a warning since "UnknownImpl" is not in the cfg.
/// #[cfg(not(pam_impl = "UnknownImpl"))]
/// fn do_something() {
///     // ...
/// }
/// ```
///
/// The [`pam_impl_name!`] macro will expand to this same value, currently
#[doc = concat!("`", env!("LIBPAMSYS_IMPL"), "`.")]
pub mod pam_impl;
#[doc(inline)]
pub use pam_impl::*;