#[non_exhaustive]pub enum Error {
InvalidKey(String),
InvalidNonce(String),
AuthenticationFailed,
NotExtractable,
Unsupported(String),
NotPermitted(String),
Other(String),
Extension(ExtensionError),
Read(Error),
ShortWrite,
}Expand description
Errors surfaced by key creation and cryptographic operations.
Mirrors the WIT types.error variant (see the doc comments in
wit/webcrypto.wit for the full contracts), plus Error::Read for
failures of a caller-supplied DataSource producer. Misuse of the API
is unrepresentable by construction — operations are one-shot calls on
immutable key resources — and so has no variant here.
#[non_exhaustive]: this enum carries Error::Read in addition to the
WIT cases, so it grows independently of the package’s own rule that a new
types.error case is semver-major. The From conversion below is
exhaustive over the WIT variant, so a case added there is a compile error
here rather than a silent fallthrough.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidKey(String)
The supplied key material is invalid for the algorithm (for example, a wrong-length raw key, or one rejected by an implementation’s key-length policy). The string is human-readable.
InvalidNonce(String)
The supplied nonce is invalid for the algorithm (for example, a wrong-length AES-GCM nonce). The string is human-readable.
AuthenticationFailed
Verification failed: the MAC tag, the signature, or the ciphertext or its associated data did not verify under the key. Deliberately carries no detail, so implementations cannot leak why verification failed.
NotExtractable
The key was created with extractable false, so its material cannot
be exported.
Unsupported(String)
The request was well-formed, but the implementation does not serve the requested algorithm parameters. The string is human-readable.
NotPermitted(String)
The key does not permit the requested operation: it was minted (or arrived from a platform keystore) with the operation’s usage disabled. The string names the refused operation.
Other(String)
An implementation-specific operational failure (an external keystore that cannot complete the operation, an input exceeding a buffering limit, …). The string is human-readable.
Extension(ExtensionError)
A named condition outside the WIT error variant’s closed set,
identified by the (origin, name) pair — the only branchable
identity; message is human-readable prose, never contract.
Handle an unrecognized pair as Error::Other. Known pairs have
constants in extension.
Read(Error)
A caller-supplied DataSource producer failed while being fed into
the operation (see DataSource::from_reader). The operation’s own
result is discarded: it was computed over a truncated input.
ShortWrite
The operation succeeded without accepting the whole source: the provider closed the stream’s read end early and then reported success. The stream-closure rule permits ending the input early only when the operation fails (a failing operation’s own error is what these wrappers report), so this indicates a defective provider, not a condition to retry.
Trait Implementations§
Source§impl Display for Error
Renders the WIT cases case-name-first — invalid-key: <detail> — plus
the Error::Read case this type adds.
impl Display for Error
Renders the WIT cases case-name-first — invalid-key: <detail> — plus
the Error::Read case this type adds.
Source§impl Error for Error
impl Error for Error
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
use the Display impl or to_string()