#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum WrapperErrorKind {
WrongParamSize,
ParamsMissing,
InconsistentParams,
UnsupportedParam,
InvalidParam,
WrongValueFromTpm,
MissingAuthSession,
InvalidHandleState,
InternalError,
}
impl std::fmt::Display for WrapperErrorKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
WrapperErrorKind::WrongParamSize => {
write!(f, "Parameter provided is of the wrong size.")
}
WrapperErrorKind::ParamsMissing => {
write!(f, "Some of the required parameters were not provided.")
}
WrapperErrorKind::InconsistentParams => write!(
f,
"The provided parameters have inconsistent values or variants."
),
WrapperErrorKind::UnsupportedParam => write!(
f,
"The provided parameter is not yet supported by the library."
),
WrapperErrorKind::InvalidParam => {
write!(f, "The provided parameter is invalid for that type.")
}
WrapperErrorKind::WrongValueFromTpm => write!(f, "The TPM returned an invalid value."),
WrapperErrorKind::MissingAuthSession => write!(f, "Missing authorization session."),
WrapperErrorKind::InvalidHandleState => write!(f, "Invalid handle state."),
WrapperErrorKind::InternalError => {
write!(f, "An unexpected error occurred within the crate.")
}
}
}
}
impl std::error::Error for WrapperErrorKind {}