openmls/framing/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! # Framing errors.
//!
//! This module contains errors related to message framing operations.

use crate::error::LibraryError;
use thiserror::Error;

// === Public ===

// Re-export errors
pub use crate::tree::secret_tree::SecretTreeError;

/// Message decryption error
#[derive(Error, Debug, PartialEq, Clone)]
pub enum MessageDecryptionError {
    /// See [`LibraryError`] for more details.
    #[error(transparent)]
    LibraryError(#[from] LibraryError),
    /// Couldn't find a ratcheting secret for the given sender and generation.
    #[error("Couldn't find a ratcheting secret for the given sender and generation.")]
    GenerationOutOfBound,
    /// An error occurred during AEAD decryption.
    #[error("An error occurred during AEAD decryption.")]
    AeadError,
    /// The WireFormat was not PrivateMessage.
    #[error("The WireFormat was not PrivateMessage.")]
    WrongWireFormat,
    /// The content is malformed.
    #[error("The content is malformed.")]
    MalformedContent,
    /// See [`SecretTreeError`] for more details.
    #[error(transparent)]
    SecretTreeError(#[from] SecretTreeError),
}

/// Message encryption error
#[derive(Error, Debug, PartialEq, Clone)]
pub(crate) enum MessageEncryptionError<StorageError> {
    /// See [`LibraryError`] for more details.
    #[error(transparent)]
    LibraryError(#[from] LibraryError),
    /// The WireFormat was not PrivateMessage.
    #[error("The WireFormat was not PrivateMessage.")]
    WrongWireFormat,
    /// See [`SecretTreeError`] for more details.
    #[error(transparent)]
    SecretTreeError(#[from] SecretTreeError),
    /// Error reading from or writing to storage
    #[error("Error reading from or writing to storage: {0}")]
    StorageError(StorageError),
}

/// MlsMessage error
#[derive(Error, Debug, Clone)]
pub enum MlsMessageError {
    /// The message could not be decoded.
    #[error("The message could not be decoded.")]
    UnableToDecode,
    /// The message (or one of its parts) is too large to be encoded.
    #[error("The message (or one of its parts) is too large to be encoded.")]
    UnableToEncode,
}

/// ProtocolMessage error
#[derive(Error, Debug, Clone)]
pub enum ProtocolMessageError {
    /// Wrong wire format
    #[error("Wrong wire format")]
    WrongWireFormat,
}