ps_datachunk/
error.rs

1use std::array::TryFromSliceError;
2
3use ps_buffer::BufferError;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum PsDataChunkError {
8    #[error(transparent)]
9    BufferError(#[from] BufferError),
10    #[error(transparent)]
11    PsCypherError(#[from] ps_cypher::PsCypherError),
12    #[error(transparent)]
13    PsHashError(#[from] ps_hash::PsHashError),
14    #[error(transparent)]
15    TryFromSliceError(#[from] TryFromSliceError),
16    #[error("Failed to serialize into an AlignedDataChunk")]
17    SerializationError,
18    #[error("The data chunk was not correctly layed out")]
19    InvalidDataChunk,
20    #[error("The hash of a chunk was incorrect")]
21    InvalidChecksum,
22    #[error("Invalid length: {0}")]
23    InvalidLength(usize),
24    #[error("This should never happen: {0}")]
25    ShouldNotHaveFailed(&'static str),
26    #[error("DataChunk content does not match the type it is being interpreted as")]
27    TypeError,
28    #[error(transparent)]
29    Rancor(#[from] rancor::Error),
30}
31
32pub type Result<T> = std::result::Result<T, PsDataChunkError>;