dig_session/error.rs
1//! Error type for the session facade.
2
3use thiserror::Error;
4
5/// Errors returned by [`crate::Session`] operations.
6///
7/// Wraps the underlying [`dig_keystore`] failure verbatim (via `#[from]`) so a
8/// caller can match on the concrete storage/crypto error without dig-session
9/// inventing a parallel error taxonomy, plus the small number of failures that
10/// are specific to session enrollment.
11#[derive(Debug, Error)]
12pub enum SessionError {
13 /// A key-storage or decryption failure surfaced by [`dig_keystore`]
14 /// (missing file, wrong password, tampered ciphertext, scheme mismatch, …).
15 #[error(transparent)]
16 Keystore(#[from] dig_keystore::KeystoreError),
17
18 /// Enrollment was asked to derive an identity from empty seed material.
19 ///
20 /// A caller must supply real BIP-39 seed bytes; deriving an identity key
21 /// from an empty seed would silently produce a fixed, guessable key.
22 #[error("seed material must be non-empty")]
23 EmptySeed,
24}
25
26/// Convenience alias for `Result<T, SessionError>`.
27pub type Result<T> = std::result::Result<T, SessionError>;