pub enum Error {
Io(Error),
Format(String),
Checksum(&'static str),
Eof(usize),
Decode(String),
Corrupt(String),
Unsupported(String),
}Expand description
Everything that can go wrong while reading a block.
The variants are deliberately coarse: callers usually only need to tell “the data is corrupt” from “the file is not what we expected” from “the I/O layer failed”. All of them are terminal for a single block, so the usual response is to skip or quarantine that block and continue.
Variants§
Io(Error)
Wraps a filesystem or memory-mapping failure.
Format(String)
The file does not follow the Prometheus on-disk layout.
Checksum(&'static str)
CRC32C mismatch in the named section (index toc, index series,
index symbols, chunk or tombstones).
Eof(usize)
A read ran past the end of the buffer, at the given absolute offset.
Decode(String)
A chunk payload could not be decoded.
Corrupt(String)
The data contradicts itself: a checksum is fine but the structure, the metadata or the cross-references do not add up.
Unsupported(String)
A format version or chunk encoding this crate does not implement.
Implementations§
Source§impl Error
impl Error
Sourcepub fn format(msg: impl Display) -> Self
pub fn format(msg: impl Display) -> Self
Builds Error::Format from anything displayable.
Sourcepub fn decode(msg: impl Display) -> Self
pub fn decode(msg: impl Display) -> Self
Builds Error::Decode from anything displayable.
Sourcepub fn corrupt(msg: impl Display) -> Self
pub fn corrupt(msg: impl Display) -> Self
Builds Error::Corrupt from anything displayable.
Sourcepub fn is_corruption(&self) -> bool
pub fn is_corruption(&self) -> bool
True when the bytes are malformed or inconsistent.
The usual response is to skip the block and keep going; IO and unsupported-version errors are not covered.
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()