pub enum ImportKeyError {
Syntax,
Type,
InvalidKeyFormat,
Generic(Error),
}
Expand description
Errors that can occur when importing cryptographic keys.
These errors map to the exceptions defined in the Web Crypto API specification for key import operations.
Variants§
Syntax
Indicates that the key usage array is empty for a secret or private key.
This error occurs when:
- No key usages are specified during import
- The key type requires at least one usage to be specified
Key usages typically include operations like “encrypt”, “decrypt”, “sign”, or “verify”.
Type
Indicates that the key data is not suitable for the specified format.
This error occurs when:
- The key data is malformed
- The key data doesn’t match the expected format
- The key data is invalid for the specified algorithm
For example, trying to import non-AES data as an AES key would trigger this error.
InvalidKeyFormat
Indicates that an invalid key format was specified during import.
This error occurs when:
- The specified format (e.g., “raw”, “pkcs8”, “spki”, “jwk”) is not supported
- The specified format is not appropriate for the key type
For example, trying to import a symmetric key using “spki” format would trigger this error.
Generic(Error)
A wrapper for other types of errors that may occur during key import.
This includes general Web Crypto API errors and other unexpected failures.
Trait Implementations§
Source§impl Clone for ImportKeyError
impl Clone for ImportKeyError
Source§fn clone(&self) -> ImportKeyError
fn clone(&self) -> ImportKeyError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ImportKeyError
impl Debug for ImportKeyError
Source§impl Display for ImportKeyError
impl Display for ImportKeyError
Source§impl Error for ImportKeyError
impl Error for ImportKeyError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<Error> for ImportKeyError
impl From<Error> for ImportKeyError
Source§impl From<JsValue> for ImportKeyError
impl From<JsValue> for ImportKeyError
Source§fn from(value: JsValue) -> Self
fn from(value: JsValue) -> Self
Converts a JavaScript value into an ImportKeyError.
Maps specific DOM exceptions to their corresponding ImportKeyError variants:
SyntaxError
→ImportKeyError::Syntax
DataError
→ImportKeyError::InvalidKeyFormat
- JavaScript
SyntaxError
→ImportKeyError::Type
- Other errors →
ImportKeyError::Generic
§Arguments
value
- The JavaScript value to convert
§Returns
The corresponding ImportKeyError variant