nectar_primitives/chunk/encryption/error.rs
1//! Encryption error types.
2
3use thiserror::Error;
4
5/// Errors from encryption operations.
6#[non_exhaustive]
7#[derive(Debug, Error)]
8pub enum EncryptionError {
9 /// Input data is shorter than the required minimum.
10 #[error("data too short: {len} bytes, minimum {min}")]
11 DataTooShort {
12 /// Actual length.
13 len: usize,
14 /// Minimum required length.
15 min: usize,
16 },
17
18 /// Input data exceeds the maximum allowed length.
19 #[error("data too long: {len} bytes, maximum {max}")]
20 DataTooLong {
21 /// Actual length.
22 len: usize,
23 /// Maximum allowed length.
24 max: usize,
25 },
26
27 /// Reference byte slice is not 32 or 64 bytes.
28 #[error("invalid reference length: {len} bytes (expected 32 or 64)")]
29 InvalidReferenceLength {
30 /// Actual length.
31 len: usize,
32 },
33
34 /// Key byte slice is not 32 bytes.
35 #[error("invalid key length: {len} bytes (expected 32)")]
36 InvalidKeyLength {
37 /// Actual length.
38 len: usize,
39 },
40
41 /// Output buffer is too small for decryption.
42 #[error("output buffer too small: {len} bytes, need {required}")]
43 OutputBufferTooSmall {
44 /// Actual buffer length.
45 len: usize,
46 /// Required buffer length.
47 required: usize,
48 },
49}