openmls/extensions/
errors.rs1use std::convert::Infallible;
13
14use crate::{
15 error::{ErrorString, LibraryError},
16 extensions::ExtensionType,
17};
18
19use thiserror::Error;
20
21#[derive(Error, Debug, PartialEq, Clone)]
23pub enum ExtensionError {
24 #[error("Unsupported proposal type in required capabilities.")]
26 UnsupportedProposalType,
27 #[error("Unsupported extension type in required capabilities.")]
29 UnsupportedExtensionType,
30 #[error(transparent)]
32 LibraryError(#[from] LibraryError),
33 #[error(transparent)]
35 InvalidExtensionType(#[from] ErrorString),
36 #[error(transparent)]
38 Capabilities(#[from] CapabilitiesExtensionError),
39 #[error(transparent)]
41 KeyPackageId(#[from] KeyPackageIdError),
42 #[error(transparent)]
44 ParentHash(#[from] ParentHashError),
45 #[error(transparent)]
47 RatchetTree(#[from] RatchetTreeError),
48 #[error(transparent)]
50 InvalidExtension(#[from] InvalidExtensionError),
51}
52
53#[derive(Error, Debug, PartialEq, Eq, Clone)]
55pub enum CapabilitiesExtensionError {
56 #[error("Invalid capabilities extensions.")]
58 Invalid,
59 #[error("Capabilities extension is missing a version field.")]
61 EmptyVersionsField,
62 #[error("Capabilities contains only unsupported ciphersuites.")]
64 UnsupportedCiphersuite,
65}
66
67#[derive(Error, Debug, PartialEq, Eq, Clone)]
69pub enum KeyPackageIdError {
70 #[error("Invalid key package ID extensions.")]
72 Invalid,
73}
74
75#[derive(Error, Debug, PartialEq, Eq, Clone)]
77pub enum ParentHashError {
78 #[error("Invalid parent hash extensions.")]
80 Invalid,
81}
82
83#[derive(Error, Debug, PartialEq, Eq, Clone)]
85pub enum RatchetTreeError {
86 #[error("Invalid ratchet tree extensions.")]
88 Invalid,
89}
90
91#[derive(Error, Debug, PartialEq, Eq, Clone)]
93pub enum InvalidExtensionError {
94 #[error("The provided extension list contains duplicate extensions.")]
96 Duplicate,
97 #[error("The specified extension could not be found.")]
99 NotFound,
100 #[error(transparent)]
102 ExtensionTypeNotValidInLeafNode(#[from] ExtensionTypeNotValidInLeafNodeError),
103 #[error(transparent)]
106 ExtensionTypeNotValidInGroupContext(#[from] ExtensionTypeNotValidInGroupContextError),
107 #[error(transparent)]
109 ExtensionTypeNotValidInKeyPackage(#[from] ExtensionTypeNotValidInKeyPackageError),
110 #[error(transparent)]
113 ExtensionTypeNotValidInGroupInfo(#[from] ExtensionTypeNotValidInGroupInfoError),
114 #[error("The provided extension cannot be added directly to the GroupInfo.")]
116 CannotAddDirectlyToGroupInfo,
117}
118
119#[derive(Error, Debug, PartialEq, Eq, Clone)]
121#[error(
122 "The provided extension list contains an extension of type {0:?} that is not allowed in the group info."
123 )]
124pub struct ExtensionTypeNotValidInGroupInfoError(pub ExtensionType);
125
126#[derive(Error, Debug, PartialEq, Eq, Clone)]
128#[error(
129 "The provided extension list contains an extension of type {0:?} that is not allowed in the group context."
130 )]
131pub struct ExtensionTypeNotValidInGroupContextError(pub ExtensionType);
132
133#[derive(Error, Debug, PartialEq, Eq, Clone)]
135#[error(
136 "The provided extension list contains an extension of type {0:?} that is not allowed in leaf nodes."
137 )]
138pub struct ExtensionTypeNotValidInLeafNodeError(pub ExtensionType);
139
140#[derive(Error, Debug, PartialEq, Eq, Clone)]
142#[error(
143 "The provided extension list contains an extension of type {0:?} that is not allowed in key packages."
144 )]
145pub struct ExtensionTypeNotValidInKeyPackageError(pub ExtensionType);
146
147impl From<Infallible> for InvalidExtensionError {
148 fn from(value: Infallible) -> Self {
149 match value {}
150 }
151}