Mercurial > crates > nonstick
comparison src/conv.rs @ 64:bbe84835d6db v0.0.5
More organization; add lots of docs.
- moves `PamHandle` to its own module, since it will be used
by both modules and clients.
- adds a ton of documentation to the `PamModule` trait
and reorders methods to most-interesting-first.
- adds more flag values from pam_modules.h.
- other misc cleanup.
| author | Paul Fisher <paul@pfish.zone> |
|---|---|
| date | Thu, 22 May 2025 01:52:32 -0400 |
| parents | a7aa5ca0d00d |
| children | 8f3ae0c7ab92 |
comparison
equal
deleted
inserted
replaced
| 63:a7aa5ca0d00d | 64:bbe84835d6db |
|---|---|
| 1 //! The [Conversation] struct, for interacting with the user. | 1 //! The [Conversation] struct, for interacting with the user. |
| 2 //! | 2 //! |
| 3 //! This module is experimental and will probably be rewritten in the future | 3 //! This module is experimental and will probably be rewritten in the future |
| 4 //! to improve the interface for both PAM modules and clients. | 4 //! to improve the interface for both PAM modules and clients. |
| 5 | 5 |
| 6 use crate::constants::MessageStyle; | |
| 7 use crate::constants::Result; | |
| 8 use crate::constants::{ErrorCode, InvalidEnum}; | |
| 9 use crate::items::Item; | |
| 6 use libc::{c_char, c_int}; | 10 use libc::{c_char, c_int}; |
| 11 use num_derive::FromPrimitive; | |
| 7 use std::ffi::{CStr, CString}; | 12 use std::ffi::{CStr, CString}; |
| 8 use std::ptr; | 13 use std::ptr; |
| 9 use num_derive::FromPrimitive; | |
| 10 use crate::constants::{ErrorCode, InvalidEnum}; | |
| 11 use crate::constants::MessageStyle; | |
| 12 use crate::constants::Result; | |
| 13 use crate::items::Item; | |
| 14 | 14 |
| 15 /// Styles of message that are shown to the user. | 15 /// Styles of message that are shown to the user. |
| 16 #[derive(Debug, PartialEq, FromPrimitive)] | 16 #[derive(Debug, PartialEq, FromPrimitive)] |
| 17 #[non_exhaustive] // non-exhaustive because C might give us back anything! | 17 #[non_exhaustive] // non-exhaustive because C might give us back anything! |
| 18 pub enum MessageStyle { | 18 pub enum MessageStyle { |
| 41 impl From<MessageStyle> for c_int { | 41 impl From<MessageStyle> for c_int { |
| 42 fn from(val: MessageStyle) -> Self { | 42 fn from(val: MessageStyle) -> Self { |
| 43 val as Self | 43 val as Self |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | |
| 47 | 46 |
| 48 #[repr(C)] | 47 #[repr(C)] |
| 49 struct Message { | 48 struct Message { |
| 50 msg_style: MessageStyle, | 49 msg_style: MessageStyle, |
| 51 msg: *const c_char, | 50 msg: *const c_char, |
