openmls/framing/
errors.rs

1//! # Framing errors.
2//!
3//! This module contains errors related to message framing operations.
4
5use crate::error::LibraryError;
6use thiserror::Error;
7
8// === Public ===
9
10// Re-export errors
11pub use crate::tree::secret_tree::SecretTreeError;
12
13/// Message decryption error
14#[derive(Error, Debug, PartialEq, Clone)]
15pub enum MessageDecryptionError {
16    /// See [`LibraryError`] for more details.
17    #[error(transparent)]
18    LibraryError(#[from] LibraryError),
19    /// Couldn't find a ratcheting secret for the given sender and generation.
20    #[error("Couldn't find a ratcheting secret for the given sender and generation.")]
21    GenerationOutOfBound,
22    /// An error occurred during AEAD decryption.
23    #[error("An error occurred during AEAD decryption.")]
24    AeadError,
25    /// The WireFormat was not PrivateMessage.
26    #[error("The WireFormat was not PrivateMessage.")]
27    WrongWireFormat,
28    /// The content is malformed.
29    #[error("The content is malformed.")]
30    MalformedContent,
31    /// See [`SecretTreeError`] for more details.
32    #[error(transparent)]
33    SecretTreeError(#[from] SecretTreeError),
34}
35
36/// Message encryption error
37#[derive(Error, Debug, PartialEq, Clone)]
38pub(crate) enum MessageEncryptionError<StorageError> {
39    /// See [`LibraryError`] for more details.
40    #[error(transparent)]
41    LibraryError(#[from] LibraryError),
42    /// The WireFormat was not PrivateMessage.
43    #[error("The WireFormat was not PrivateMessage.")]
44    WrongWireFormat,
45    /// See [`SecretTreeError`] for more details.
46    #[error(transparent)]
47    SecretTreeError(#[from] SecretTreeError),
48    /// Error reading from or writing to storage
49    #[error("Error reading from or writing to storage: {0}")]
50    StorageError(StorageError),
51}
52
53/// MlsMessage error
54#[derive(Error, Debug, Clone)]
55pub enum MlsMessageError {
56    /// The message could not be decoded.
57    #[error("The message could not be decoded.")]
58    UnableToDecode,
59    /// The message (or one of its parts) is too large to be encoded.
60    #[error("The message (or one of its parts) is too large to be encoded.")]
61    UnableToEncode,
62}
63
64/// ProtocolMessage error
65#[derive(Error, Debug, Clone)]
66pub enum ProtocolMessageError {
67    /// Wrong wire format
68    #[error("Wrong wire format")]
69    WrongWireFormat,
70}