Mercurial > crates > nonstick
diff src/constants.rs @ 71:58f9d2a4df38
Reorganize everything again???
- Splits ffi/memory stuff into a bunch of stuff in the pam_ffi module.
- Builds infrastructure for passing Messages and Responses.
- Adds tests for some things at least.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Tue, 03 Jun 2025 21:54:58 -0400 |
parents | 9f8381a1c09c |
children | 351bdc13005e |
line wrap: on
line diff
--- a/src/constants.rs Tue Jun 03 01:21:59 2025 -0400 +++ b/src/constants.rs Tue Jun 03 21:54:58 2025 -0400 @@ -6,6 +6,7 @@ use num_traits::FromPrimitive; use std::any; use std::marker::PhantomData; +use std::result::Result as StdResult; bitflags! { /// The available PAM flags. @@ -137,7 +138,7 @@ } /// A PAM-specific Result type with an [ErrorCode] error. -pub type Result<T> = std::result::Result<T, ErrorCode>; +pub type Result<T> = StdResult<T, ErrorCode>; impl ErrorCode { /// Converts this [Result] into a C-compatible result code. @@ -161,7 +162,7 @@ impl TryFrom<c_int> for ErrorCode { type Error = InvalidEnum<Self>; - fn try_from(value: c_int) -> std::result::Result<Self, Self::Error> { + fn try_from(value: c_int) -> StdResult<Self, Self::Error> { Self::from_i32(value).ok_or(value.into()) } } @@ -193,18 +194,6 @@ /// Returned when text that should not have any `\0` bytes in it does. /// Analogous to [`std::ffi::NulError`], but the data it was created from /// is borrowed. -#[derive(Debug, thiserror::Error)] -#[error("null byte within input at byte {0}")] -pub struct NulError(pub usize); - -/// Returned when trying to fit too much data into a binary message. -#[derive(Debug, thiserror::Error)] -#[error("cannot create a message of {actual} bytes; maximum is {max}")] -pub struct TooBigError { - pub actual: usize, - pub max: usize, -} - #[cfg(test)] mod tests { use super::*;