Skip to main content

Error

Enum Error 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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 Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Renders the WIT cases case-name-first — invalid-key: <detail> — plus the Error::Read case this type adds.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Resource for T
where T: 'static,

§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.