Skip to main content

ps_hkey/
error.rs

1use ps_datachunk::DataChunkError;
2use ps_hash::{HashError, HashValidationError};
3use std::num::ParseIntError;
4use std::str::Utf8Error;
5use thiserror::Error;
6
7#[derive(Error, Debug)]
8pub enum HkeyError {
9    #[error(transparent)]
10    Construction(#[from] HkeyConstructionError),
11    #[error(transparent)]
12    Hash(#[from] HashError),
13    #[error(transparent)]
14    HashValidation(#[from] HashValidationError),
15    #[error(transparent)]
16    ParseInt(#[from] ParseIntError),
17    #[error(transparent)]
18    DataChunk(#[from] DataChunkError),
19    #[error(transparent)]
20    Utf8(#[from] Utf8Error),
21
22    #[error("Invalid hkey format")]
23    Format,
24    #[error("Invalid range, entity is of size {0}")]
25    Range(usize),
26    #[error("Failed to store with external storage function")]
27    Storage,
28    #[error("While storing a List or LongHkey, expected Hkey::Encrypted, got {0}")]
29    EncryptedIntoListRef(crate::Hkey),
30    #[error("Reached unreachable code.")]
31    Unreachable,
32}
33
34pub type Result<T, E = HkeyError> = std::result::Result<T, E>;
35
36#[derive(Error, Debug)]
37pub enum HkeyConstructionError {
38    #[error("Maximum length exceeded.")]
39    TooLong,
40}
41
42#[derive(Error, Debug)]
43pub enum HkeyFromCompactError {
44    #[error(transparent)]
45    Construction(#[from] HkeyConstructionError),
46    #[error("Hash validation error: {0}")]
47    HashValidation(#[from] ps_hash::HashValidationError),
48}