#[non_exhaustive]pub enum TokenPrivilegeError {
OpenTokenFailed(Error),
QueryFailed(Error),
InvalidPrivilegeName {
name: String,
},
LookupFailed {
name: String,
source: Error,
},
CheckFailed(Error),
UnsupportedPlatform,
}Expand description
Errors that can occur when querying token privileges.
This enum is #[non_exhaustive] to allow adding new error variants in
future minor releases without breaking downstream code. Always include
a wildcard arm when matching.
§Examples
use token_privilege::TokenPrivilegeError;
fn handle_error(err: TokenPrivilegeError) {
match err {
TokenPrivilegeError::UnsupportedPlatform => {
eprintln!("This feature requires Windows");
}
other => eprintln!("Token error: {other}"),
}
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
OpenTokenFailed(Error)
Failed to open the process token.
This typically occurs if the process lacks sufficient permissions to query its own token (very rare in practice).
QueryFailed(Error)
Failed to query token information.
Returned when GetTokenInformation fails after the token
has been successfully opened.
InvalidPrivilegeName
The specified privilege name is invalid or not recognized.
The Windows privilege name (e.g., "SeDebugPrivilege") was not
found in the system’s privilege database.
LookupFailed
Failed to look up the privilege value for the given name.
Unlike InvalidPrivilegeName, this
indicates an OS-level failure during the lookup rather than an
unknown privilege name.
Fields
CheckFailed(Error)
Failed to check privilege status.
Returned when PrivilegeCheck fails after the privilege LUID
has been successfully resolved.
UnsupportedPlatform
This functionality is only available on Windows.
All public functions in this crate return this error on non-Windows
platforms. This allows downstream crates to depend on token-privilege
unconditionally and handle the non-Windows case gracefully.