#[non_exhaustive]pub enum Error {
Show 20 variants
BadMagic {
got: [u8; 8],
},
UnsupportedVersion {
found_major: u16,
found_minor: u16,
supported_major: u16,
},
Truncated {
context: &'static str,
need: usize,
got: usize,
},
MalformedHeader {
reason: &'static str,
},
NoMatchingSlot,
HeaderMacMismatch,
ChunkAuthFailed {
index: u64,
},
UnknownCriticalTlv {
tlv_type: u16,
},
MissingTlv {
tlv_type: u16,
},
MalformedTlv {
tlv_type: u16,
reason: &'static str,
},
ChunkOutOfRange {
index: u64,
total: u64,
},
TooManySlots {
got: usize,
max: usize,
},
InvalidChunkSize {
got: u32,
min: u32,
max: u32,
},
ShardCrcMismatch {
index: u32,
expected: u32,
computed: u32,
},
MissingShards {
missing: Vec<u32>,
total: u32,
},
ShardUuidMismatch {
index: u32,
},
ContentHashMismatch,
Compression {
reason: String,
},
KeyDerivation {
reason: &'static str,
},
Io(Error),
}Expand description
omy 核心库的错误类型。
每个变体都携带定位问题所需的结构化字段,供上层渲染本地化消息。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
BadMagic
文件头 magic 不匹配,不是 omy 文件。
UnsupportedVersion
主版本号高于本实现支持的上限,必须拒绝打开(规范 §9 步骤 2)。
Truncated
输入数据长度不足,无法解析出完整结构。
MalformedHeader
头部字段取值非法或自相矛盾。
NoMatchingSlot
没有任何候选密钥能解开任何一个 key slot。
注意:这不代表文件损坏,也可能只是该文件不属于当前解锁的密码。 面向用户的文案必须同时表达这两种可能。
HeaderMacMismatch
头部 HMAC 校验失败:文件被篡改,或 FEK 不正确。
规范 §7 要求此时必须终止,不得继续读取载荷。
ChunkAuthFailed
载荷块的 AEAD 认证失败。
UnknownCriticalTlv
遇到未知且标记为 CRITICAL 的 TLV,按规范必须拒绝打开(§4.2)。
MissingTlv
必需的 TLV 缺失。
MalformedTlv
TLV 内容解析失败。
ChunkOutOfRange
请求的块序号超出文件实际块数。
TooManySlots
key slot 数量超过格式上限。
InvalidChunkSize
分块大小超出允许范围。
ShardCrcMismatch
分片的 CRC-32 校验失败。
MissingShards
分片集合中缺少某些序号。
ShardUuidMismatch
分片的 file_uuid 与其它片不一致,属于不同文件。
ContentHashMismatch
解密后内容哈希与 TLV_CONTENT_HASH 记录不符。
Compression
压缩或解压失败。
KeyDerivation
密钥派生失败。
Io(Error)
底层 IO 错误。
Implementations§
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Forget for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more