Skip to main content

openmls/targeted_messages/
errors.rs

1//! Errors for targeted messages.
2
3use thiserror::Error;
4
5use crate::error::LibraryError;
6
7/// Error creating a targeted message.
8#[derive(Debug, Error)]
9pub enum CreateTargetedMessageError {
10    /// The recipient's leaf index is not in the group tree.
11    #[error("The recipient is not a member of the group.")]
12    RecipientNotFound,
13    /// The group is not active.
14    #[error("The group is not in an active state.")]
15    GroupNotActive,
16    /// A library error occurred.
17    #[error(transparent)]
18    LibraryError(#[from] LibraryError),
19}
20
21/// Error processing a targeted message.
22#[derive(Debug, Error)]
23pub enum ProcessTargetedMessageError<StorageError> {
24    /// The group ID in the message doesn't match.
25    #[error("The group ID in the targeted message does not match.")]
26    GroupIdMismatch,
27    /// The epoch in the message doesn't match.
28    #[error("The epoch in the targeted message does not match.")]
29    EpochMismatch,
30    /// The message was not intended for this recipient.
31    #[error("The recipient leaf index does not match own leaf index.")]
32    NotIntendedRecipient,
33    /// The sender's leaf index refers to a blank leaf.
34    #[error("The sender's leaf index refers to a blank or missing leaf.")]
35    SenderNotFound,
36    /// Decryption of sender auth data failed.
37    #[error("Failed to decrypt sender authentication data.")]
38    SenderAuthDataDecryptionFailed,
39    /// The sender auth data could not be deserialized.
40    #[error("Malformed sender authentication data.")]
41    MalformedSenderAuthData,
42    /// Signature verification failed.
43    #[error("Signature verification on targeted message failed.")]
44    SignatureVerificationFailed,
45    /// Decryption of the message content failed.
46    #[error("Failed to decrypt targeted message content.")]
47    ContentDecryptionFailed,
48    /// The decrypted content could not be deserialized.
49    #[error("Malformed targeted message content.")]
50    MalformedContent,
51    /// The group is not active.
52    #[error("The group is not in an active state.")]
53    GroupNotActive,
54    /// Error reading from storage.
55    #[error("Error reading from storage: {0}")]
56    StorageError(StorageError),
57    /// A library error occurred.
58    #[error(transparent)]
59    LibraryError(#[from] LibraryError),
60}