pub struct PtrPtrVec<T> { /* private fields */ }Expand description
A pointer-to-pointer-to-message container for PAM’s conversation callback.
The PAM conversation callback requires a pointer to a pointer of
pam_messages. Linux-PAM handles this differently than all other
PAM implementations (including the X/SSO PAM standard).
X/SSO appears to specify a pointer-to-pointer-to-array:
points to ┌────────────┐ ╔═ Message[] ═╗
messages ┄┄┄┄┄┄┄┄┄┄> │ *messages ┄┼┄┄┄┄┄> ║ style ║
└────────────┘ ║ data ┄┄┄┄┄┄┄╫┄┄> ...
╟─────────────╢
║ style ║
║ data ┄┄┄┄┄┄┄╫┄┄> ...
╟─────────────╢
║ ... ║whereas Linux-PAM uses an **argv-style pointer-to-array-of-pointers:
points to ┌──────────────┐ ╔═ Message ═╗
messages ┄┄┄┄┄┄┄┄┄┄> │ messages[0] ┄┼┄┄┄┄> ║ style ║
│ messages[1] ┄┼┄┄┄╮ ║ data ┄┄┄┄┄╫┄┄> ...
│ ... │ ┆ ╚═══════════╝
┆
┆ ╔═ Message ═╗
╰┄┄> ║ style ║
║ data ┄┄┄┄┄╫┄┄> ...
╚═══════════╝Because the messages remain owned by the application which calls into PAM,
we can solve this with One Simple Trick: make the intermediate list point
into the same array:
points to ┌──────────────┐ ╔═ Message[] ═╗
messages ┄┄┄┄┄┄┄┄┄┄> │ messages[0] ┄┼┄┄┄┄> ║ style ║
│ messages[1] ┄┼┄┄╮ ║ data ┄┄┄┄┄┄┄╫┄┄> ...
│ ... │ ┆ ╟─────────────╢
╰┄> ║ style ║
║ data ┄┄┄┄┄┄┄╫┄┄> ...
╟─────────────╢
║ ... ║Implementations§
Source§impl<T> PtrPtrVec<T>
impl<T> PtrPtrVec<T>
Sourcepub fn new(data: Vec<T>) -> Self
pub fn new(data: Vec<T>) -> Self
Takes ownership of the given Vec and creates a vec of pointers to it.
Sourcepub fn into_inner(self) -> Vec<T>
pub fn into_inner(self) -> Vec<T>
Gives you back your Vec.
Sourcepub fn as_ptr<Dest>(&self) -> *const *const Dest
pub fn as_ptr<Dest>(&self) -> *const *const Dest
Gets a pointer-to-pointer suitable for passing into the Conversation.
Sourcepub unsafe fn iter_over_linux<'a, Src>(
ptr_ptr: *const *const Src,
count: usize,
) -> impl Iterator<Item = &'a T>where
T: 'a,
👎Deprecated: use Self::iter_over instead, unless you really need this specific version
pub unsafe fn iter_over_linux<'a, Src>(
ptr_ptr: *const *const Src,
count: usize,
) -> impl Iterator<Item = &'a T>where
T: 'a,
use Self::iter_over instead, unless you really need this specific version
Iterates over a Linux-PAM–style pointer-to-array-of-pointers.
§Safety
ptr_ptr must be a valid pointer to an array of pointers,
there must be at least count valid pointers in the array,
and each pointer in that array must point to a valid T.
Sourcepub unsafe fn iter_over_xsso<'a, Src>(
ptr_ptr: *const *const Src,
count: usize,
) -> impl Iterator<Item = &'a T>where
T: 'a,
👎Deprecated: use Self::iter_over instead, unless you really need this specific version
pub unsafe fn iter_over_xsso<'a, Src>(
ptr_ptr: *const *const Src,
count: usize,
) -> impl Iterator<Item = &'a T>where
T: 'a,
use Self::iter_over instead, unless you really need this specific version
Iterates over an X/SSO–style pointer-to-pointer-to-array.
§Safety
You must pass a valid pointer to a valid pointer to an array,
there must be at least count elements in the array,
and each value in that array must be a valid T.
Sourcepub unsafe fn iter_over<'a, Src>(
ptr_ptr: *const *const Src,
count: usize,
) -> impl Iterator<Item = &'a T>where
T: 'a,
pub unsafe fn iter_over<'a, Src>(
ptr_ptr: *const *const Src,
count: usize,
) -> impl Iterator<Item = &'a T>where
T: 'a,
Iterates over a PAM message list appropriate to your system’s impl.
This selects the correct pointer/array structure to use for a message that was given to you by your system.
§Safety
ptr_ptr must point to a valid message list, there must be at least
count messages in the list, and all messages must be a valid Src.