comparison libpam-sys/libpam-sys-helpers/src/lib.rs @ 158:d5b7b28d754e

Add `__TARGET_DEFAULT__` PamImpl and set up for docsrs build. Also fixes some formatting stuff.
author Paul Fisher <paul@pfish.zone>
date Sat, 12 Jul 2025 17:17:37 -0400
parents 14708d9061dc
children 9e4ce1631bd3
comparison
equal deleted inserted replaced
157:0099f2f79f86 158:d5b7b28d754e
4 use std::error::Error; 4 use std::error::Error;
5 use std::marker::{PhantomData, PhantomPinned}; 5 use std::marker::{PhantomData, PhantomPinned};
6 use std::mem::ManuallyDrop; 6 use std::mem::ManuallyDrop;
7 use std::ptr::NonNull; 7 use std::ptr::NonNull;
8 use std::{any, fmt, mem, ptr, slice}; 8 use std::{any, fmt, mem, ptr, slice};
9 // Type aliases:
10 9
11 // Memory management 10 // Memory management
12 11
13 /// A pointer-to-pointer-to-message container for PAM's conversation callback. 12 /// A pointer-to-pointer-to-message container for PAM's conversation callback.
14 /// 13 ///
570 // make sure they're not accidentally allocated adjacently 569 // make sure they're not accidentally allocated adjacently
571 // in such a way that it's compatible with X/SSO. 570 // in such a way that it's compatible with X/SSO.
572 // 571 //
573 // a pointer to (&str, i32) can be treated as a pointer to (&str). 572 // a pointer to (&str, i32) can be treated as a pointer to (&str).
574 #[repr(C)] 573 #[repr(C)]
575 struct pair(&'static str, i32); 574 struct Pair(&'static str, i32);
576 let boxes = vec![ 575 let boxes = vec![
577 Box::new(pair("a", 1)), 576 Box::new(Pair("a", 1)),
578 Box::new(pair("b", 2)), 577 Box::new(Pair("b", 2)),
579 Box::new(pair("c", 3)), 578 Box::new(Pair("c", 3)),
580 Box::new(pair("D", 4)), 579 Box::new(Pair("D", 4)),
581 ]; 580 ];
582 let ptr: *const *const &str = boxes.as_ptr().cast(); 581 let ptr: *const *const &str = boxes.as_ptr().cast();
583 let got: Vec<&str> = unsafe { PtrPtrVec::iter_over_linux(ptr, 4) } 582 let got: Vec<&str> = unsafe { PtrPtrVec::iter_over_linux(ptr, 4) }
584 .cloned() 583 .cloned()
585 .collect(); 584 .collect();