Mercurial > crates > nonstick
comparison libpam-sys/libpam-sys-impls/src/lib.rs @ 176:0730f5f2ee2a
Turn `libpam-sys-consts` back into `libpam-sys-impls`.
This moves the constants into `libpam-sys` and makes `libpam-sys-impls`
responsible solely for detecting the current PAM implementation.
| author | Paul Fisher <paul@pfish.zone> |
|---|---|
| date | Wed, 30 Jul 2025 17:53:31 -0400 |
| parents | libpam-sys/libpam-sys-consts/src/lib.rs@e9354e655f38 |
| children | 995aca290452 |
comparison
equal
deleted
inserted
replaced
| 175:e30775c80b49 | 176:0730f5f2ee2a |
|---|---|
| 1 //! Information about the PAM implementation you're using right now. | |
| 2 //! | |
| 3 //! This module contains constants and values that can be used at build-script, | |
| 4 //! compile, and run time to determine what PAM implementation you're using. | |
| 5 //! | |
| 6 //! ## Always available | |
| 7 //! | |
| 8 //! [`PamImpl::CURRENT`] will tell you what version of PAM you're using. | |
| 9 //! It can be imported in any Rust code, from build scripts to runtime. | |
| 10 //! | |
| 11 //! ## Compile time | |
| 12 //! | |
| 13 //! Use [`enable_pam_impl_cfg`] in your `build.rs` to generate custom `#[cfg]`s | |
| 14 //! for conditional compilation based on PAM implementation. | |
| 15 //! | |
| 16 //! ``` | |
| 17 //! // Your package's build.rs: | |
| 18 //! | |
| 19 //! fn main() { | |
| 20 //! // Also available at libpam_sys::pam_impl::enable_pam_impl_cfg(). | |
| 21 //! libpam_sys_impls::enable_pam_impl_cfg(); | |
| 22 //! // whatever else you do in your build script. | |
| 23 //! } | |
| 24 //! ``` | |
| 25 //! | |
| 26 //! This will set the current `pam_impl` as well as registering all known | |
| 27 //! PAM implementations with `rustc-check-cfg` to get cfg-checking. | |
| 28 //! | |
| 29 //! The names that appear in the `cfg` variables are the same as the values | |
| 30 //! in the [`PamImpl`] enum. | |
| 31 //! | |
| 32 //! ```ignore | |
| 33 //! #[cfg(pam_impl = "OpenPam")] | |
| 34 //! fn openpam_specific_func(handle: *const libpam_sys::pam_handle) { | |
| 35 //! let environ = libpam_sys::pam_getenvlist(handle); | |
| 36 //! // ... | |
| 37 //! libpam_sys::openpam_free_envlist() | |
| 38 //! } | |
| 39 //! | |
| 40 //! // This will give you a warning since "UnknownImpl" is not in the cfg. | |
| 41 //! #[cfg(not(pam_impl = "UnknownImpl"))] | |
| 42 //! fn do_something() { | |
| 43 //! // ... | |
| 44 //! } | |
| 45 //! ``` | |
| 46 //! | |
| 47 //! The [`pam_impl_name!`] macro will expand to this same value, currently | |
| 48 #![doc = concat!("`", env!("LIBPAMSYS_IMPL"), "`.")] | |
| 49 | |
| 50 mod pam_impl; | |
| 51 | |
| 52 #[doc(inline)] | |
| 53 pub use pam_impl::*; |
