#[non_exhaustive]pub enum Error {
Truncated,
UnknownCodec(u8),
UnknownCrypto(u8),
Corrupt,
Auth,
Utf8 {
valid_up_to: usize,
},
}Expand description
Everything that can go wrong decoding an entry, shared by every crate in the toolkit.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Truncated
The input ended in the middle of a header or payload. Distinct from
Corrupt: the bytes present were well formed,
there were simply not enough of them.
UnknownCodec(u8)
The entry’s tag byte names a codec id that is either unassigned or not compiled into this build. Carries the id as read.
UnknownCrypto(u8)
The entry’s tag byte names a cipher id that is either unassigned or not compiled into this build. Carries the id as read.
Also returned for CryptoId::None where a
real cipher was required, since nothing is ever sealed under it.
Corrupt
The bytes are structurally invalid: a payload the named codec cannot decode, a varint longer than ten bytes, or output whose length disagrees with the length the header declared.
A decoder also reports this rather than aborting when the header claims a length too large to allocate, so a hostile entry costs a failed reservation rather than the process.
Auth
The AEAD tag does not authenticate the payload under the key and nonce supplied: a wrong key, a tampered entry, or both. The plaintext is never returned in this case, even partially.
Utf8
The decoded bytes were requested as a string but are not valid UTF-8.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()