use std::io;
pub type Result<T> = std::result::Result<T, LuksError>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum LuksError {
#[error("not a LUKS container: magic is {found:02x?}, expected 4c554b53babe")]
NotLuks {
found: [u8; 6],
},
#[error("unsupported LUKS version {version} (only 1 and 2 are supported)")]
UnsupportedVersion {
version: u16,
},
#[error("unsupported {what}: {value:?}")]
Unsupported {
what: &'static str,
value: String,
},
#[error("malformed LUKS header: {what} (need {need} bytes, have {got})")]
MalformedHeader {
what: &'static str,
need: usize,
got: usize,
},
#[error("authentication failed: no keyslot matched the passphrase")]
AuthenticationFailed,
#[error("no active keyslot in the LUKS header")]
NoActiveKeyslot,
#[error("I/O error: {0}")]
Io(#[from] io::Error),
}