Mercurial > crates > nonstick
view src/environ.rs @ 190:995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
The previous structure of libpam-sys-impls meant that things got
confusing (including for me) between what constants were build-time
and what constants were run-time. This broke cross-compilation.
This simplifies the way that works so that `libpam-sys-impls` has
*no* build script itself and is intended mostly as a library to be
included in other libraries' build scripts (while also exporting
the PamImpl enum).
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sat, 02 Aug 2025 18:47:46 -0400 |
parents | a508a69c068a |
children | 5074d8e00560 |
line wrap: on
line source
//! Traits and stuff for managing the environment of a PAM handle. //! //! PAM modules can set environment variables to apply to a user session. //! This module manages the interface for doing all of that. use std::ffi::{OsStr, OsString}; /// A key/value map for environment variables, as [`OsString`]s. /// /// This is a limited subset of what [`HashMap`](std::collections::HashMap) /// can do. Notably, we do *not* support mutable iteration. pub trait EnvironMap<'a> { /// Gets the environment variable of the given key. fn get(&self, key: impl AsRef<OsStr>) -> Option<OsString>; /// Iterates over the key/value pairs of the environment. fn iter(&self) -> impl Iterator<Item = (OsString, OsString)>; } pub trait EnvironMapMut<'a>: EnvironMap<'a> { /// Sets the environment variable with the given key, /// returning the old one if present. fn insert(&mut self, key: impl AsRef<OsStr>, val: impl AsRef<OsStr>) -> Option<OsString>; /// Removes the environment variable from the map, returning its old value /// if present. fn remove(&mut self, key: impl AsRef<OsStr>) -> Option<OsString>; }