#[non_exhaustive]pub enum PersistError {
Show 13 variants
Io {
path: PathBuf,
source: Error,
},
BadMagic {
found: [u8; 8],
},
UnsupportedVersion {
found: u32,
supported: u32,
},
ChecksumMismatch {
expected: u32,
computed: u32,
},
TruncatedHeader {
needed: usize,
found: usize,
},
TruncatedPayload {
needed: u64,
found: u64,
},
InvalidMetric {
tag: u8,
},
UnsupportedMetric {
metric: DistanceMetric,
},
InvalidIndexType {
found: String,
expected: &'static str,
},
InvalidPayload {
reason: &'static str,
},
Compression {
reason: &'static str,
},
IndexBuild(IqdbError),
Unsupported {
feature: &'static str,
available_in: &'static str,
},
}Expand description
An error from an iqdb-persist save, load, or format operation.
Each variant identifies one specific failure. The enum is
#[non_exhaustive]: future releases may add variants without it
being a breaking change, so a match on it must include a wildcard
arm.
§Examples
use iqdb_persist::PersistError;
let err = PersistError::ChecksumMismatch { expected: 0xDEADBEEF, computed: 0x00000000 };
assert!(err.to_string().contains("checksum mismatch"));
let unsup = PersistError::Unsupported { feature: "compression", available_in: "v0.4" };
assert!(unsup.to_string().contains("v0.4"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Io
An OS-level I/O failure occurred while reading or writing a
snapshot file. path is the file whose operation failed;
source is the underlying std::io::Error and is reachable via
std::error::Error::source.
BadMagic
The first eight bytes of the file did not match
crate::MAGIC — the file is not an iqdb snapshot.
UnsupportedVersion
The header’s format-version field is not one this build supports.
found is what the file declared; supported is the version this
build writes.
Fields
ChecksumMismatch
The CRC32 of the payload bytes did not match the header’s stored value — the payload is corrupted or has been tampered with.
Fields
TruncatedHeader
The file ended before the full header could be read. needed is
the number of bytes the parser still wanted; found is how many
were available.
TruncatedPayload
The file ended before the full payload could be read.
Fields
InvalidMetric
The header’s metric tag does not correspond to any
iqdb_types::DistanceMetric variant this build knows about.
UnsupportedMetric
A DistanceMetric this build has no on-disk tag for. Only
occurs on save if a newer iqdb-types introduced a metric
variant that this build of iqdb-persist predates —
DistanceMetric is #[non_exhaustive].
Fields
metric: DistanceMetricThe metric that could not be encoded.
InvalidIndexType
The header’s index-type tag does not match the concrete I’s
crate::Persistable::INDEX_TYPE.
Fields
InvalidPayload
The payload bytes decoded successfully at the byte level but produced a structurally invalid index.
Compression
A compression or decompression step failed: an invalid codec
parameter on save, or a codec error / length mismatch on load.
(Bulk on-disk corruption is caught earlier by the payload CRC32 and
surfaces as ChecksumMismatch.)
IndexBuild(IqdbError)
A nested IqdbError surfaced from a downstream construction
step — typically iqdb_index::Index::new or
iqdb_index::IndexCore::insert called from inside a
crate::Persistable::load_from impl.
Unsupported
A configuration value asked for a feature that this build does not implement yet.
Trait Implementations§
Source§impl Debug for PersistError
impl Debug for PersistError
Source§impl Display for PersistError
impl Display for PersistError
Source§impl Error for PersistError
impl Error for PersistError
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()