Mercurial > crates > nonstick
diff src/items.rs @ 62:d83623951070
Further improve docs and put `conv` behind a feature gate.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Wed, 21 May 2025 23:10:09 -0400 |
parents | 05cc2c27334f |
children |
line wrap: on
line diff
--- a/src/items.rs Wed May 21 19:01:17 2025 -0400 +++ b/src/items.rs Wed May 21 23:10:09 2025 -0400 @@ -21,7 +21,7 @@ Tty = 3, /// The remote host (if applicable). RemoteHost = 4, - /// The [crate::Conversation] structure. + /// The conversation struct (not a CStr-based item). Conversation = 5, /// The authentication token (password). AuthTok = 6, @@ -54,29 +54,32 @@ } } -/// A type that can be requested by [crate::PamHandle::get_item]. +/// A type that can be requested by [`PamHandle::get_item`](crate::PamHandle::get_item). pub trait Item { /// The `repr(C)` type that is returned (by pointer) by the underlying `pam_get_item` function. + /// This memory is owned by the PAM session. type Raw; - /// The `ItemType` for this type + /// The [ItemType] corresponding to this Rust type. fn type_id() -> ItemType; /// The function to convert from the pointer to the C-representation to this safer wrapper type. /// /// # Safety /// - /// This function assumes the pointer is a valid pointer to a `Self::Raw` instance. + /// This function assumes the pointer is a valid pointer to a [Self::Raw] instance. unsafe fn from_raw(raw: *const Self::Raw) -> Self; /// The function to convert from this wrapper type to a C-compatible pointer. fn into_raw(self) -> *const Self::Raw; } +/// Macro to generate PAM [Item]s represented as [CStr]s. macro_rules! cstr_item { ($name:ident) => { - #[doc = concat!("The [ItemType::", stringify!($name), "]")] - #[doc = " item, represented as a [CStr]."] + #[doc = "The [CStr] representation of the "] + #[doc = concat!("[`", stringify!($name), "`](ItemType::", stringify!($name), ")")] + #[doc = " [Item]."] #[derive(Debug)] pub struct $name<'s>(pub &'s CStr);