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