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 TryFromSliceError(#[from] TryFromSliceError),
23 #[error("Failed to serialize into an AlignedDataChunk")]
24 SerializationError,
25 #[error("The data chunk was not correctly layed out")]
26 InvalidDataChunk,
27 #[error("The hash of a chunk was incorrect")]
28 InvalidHash,
29 #[error("Invalid length: {0}")]
30 InvalidLength(usize),
31 #[error("Rkyv deserialization failed")]
32 RkyvInvalidArchive,
33 #[error("Rkyv serialization failed")]
34 RkyvSerializationFailed,
35 #[error("This should never happen: {0}")]
36 ShouldNotHaveFailed(&'static str),
37 #[error("DataChunk content does not match the type it is being interpreted as")]
38 TypeError,
39}
40
41pub type Result<T> = std::result::Result<T, PsDataChunkError>;