use std::convert::Infallible;
use crate::{
error::{ErrorString, LibraryError},
extensions::ExtensionType,
};
use thiserror::Error;
#[derive(Error, Debug, PartialEq, Clone)]
pub enum ExtensionError {
#[error("Unsupported proposal type in required capabilities.")]
UnsupportedProposalType,
#[error("Unsupported extension type in required capabilities.")]
UnsupportedExtensionType,
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
InvalidExtensionType(#[from] ErrorString),
#[error(transparent)]
Capabilities(#[from] CapabilitiesExtensionError),
#[error(transparent)]
KeyPackageId(#[from] KeyPackageIdError),
#[error(transparent)]
ParentHash(#[from] ParentHashError),
#[error(transparent)]
RatchetTree(#[from] RatchetTreeError),
#[error(transparent)]
InvalidExtension(#[from] InvalidExtensionError),
}
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum CapabilitiesExtensionError {
#[error("Invalid capabilities extensions.")]
Invalid,
#[error("Capabilities extension is missing a version field.")]
EmptyVersionsField,
#[error("Capabilities contains only unsupported ciphersuites.")]
UnsupportedCiphersuite,
}
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum KeyPackageIdError {
#[error("Invalid key package ID extensions.")]
Invalid,
}
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum ParentHashError {
#[error("Invalid parent hash extensions.")]
Invalid,
}
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum RatchetTreeError {
#[error("Invalid ratchet tree extensions.")]
Invalid,
}
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum InvalidExtensionError {
#[error("The provided extension list contains duplicate extensions.")]
Duplicate,
#[error("The specified extension could not be found.")]
NotFound,
#[error(transparent)]
ExtensionTypeNotValidInLeafNode(#[from] ExtensionTypeNotValidInLeafNodeError),
#[error(transparent)]
ExtensionTypeNotValidInGroupContext(#[from] ExtensionTypeNotValidInGroupContextError),
#[error(transparent)]
ExtensionTypeNotValidInKeyPackage(#[from] ExtensionTypeNotValidInKeyPackageError),
#[error(transparent)]
ExtensionTypeNotValidInGroupInfo(#[from] ExtensionTypeNotValidInGroupInfoError),
#[error("The provided extension cannot be added directly to the GroupInfo.")]
CannotAddDirectlyToGroupInfo,
}
#[derive(Error, Debug, PartialEq, Eq, Clone)]
#[error(
"The provided extension list contains an extension of type {0:?} that is not allowed in the group info."
)]
pub struct ExtensionTypeNotValidInGroupInfoError(pub ExtensionType);
#[derive(Error, Debug, PartialEq, Eq, Clone)]
#[error(
"The provided extension list contains an extension of type {0:?} that is not allowed in the group context."
)]
pub struct ExtensionTypeNotValidInGroupContextError(pub ExtensionType);
#[derive(Error, Debug, PartialEq, Eq, Clone)]
#[error(
"The provided extension list contains an extension of type {0:?} that is not allowed in leaf nodes."
)]
pub struct ExtensionTypeNotValidInLeafNodeError(pub ExtensionType);
#[derive(Error, Debug, PartialEq, Eq, Clone)]
#[error(
"The provided extension list contains an extension of type {0:?} that is not allowed in key packages."
)]
pub struct ExtensionTypeNotValidInKeyPackageError(pub ExtensionType);
impl From<Infallible> for InvalidExtensionError {
fn from(value: Infallible) -> Self {
match value {}
}
}