mx-core 0.1.0

Core utilities for MultiversX Rust services.
Documentation
//! Typed error types for mx-core.
//!
//! Provides [`CoreError`] so that callers can programmatically distinguish
//! failure modes without resorting to string matching.

/// Errors returned by mx-core public functions.
#[derive(Debug, thiserror::Error)]
pub enum CoreError {
    /// The input is not a valid bech32 string.
    #[error("invalid bech32 address: {0}")]
    InvalidBech32(String),

    /// Decoded address does not have the expected byte length.
    #[error("invalid address length: expected 32 bytes, got {0}")]
    InvalidAddressLength(usize),

    /// Address byte slice is empty.
    #[error("empty address")]
    EmptyAddress,

    /// BIP39 mnemonic is invalid.
    #[error("invalid mnemonic: {0}")]
    InvalidMnemonic(String),

    /// A private key derivation step failed.
    #[error("invalid private key: {0}")]
    InvalidPrivateKey(String),

    /// Wallet creation from a derived private key failed.
    #[error("failed to create wallet: {0}")]
    WalletCreation(String),

    /// A numeric value could not be parsed.
    #[error("invalid numeric value: {0}")]
    InvalidNumeric(String),

    /// A protobuf big integer field does not use the expected Go BigIntCaster encoding.
    #[error("invalid BigIntCaster encoding: {0}")]
    InvalidBigIntEncoding(String),

    /// Base64 decoding failed.
    #[error("invalid base64: {0}")]
    InvalidBase64(String),

    /// Hex decoding failed.
    #[error("invalid hex: {0}")]
    InvalidHex(String),

    /// Bech32 encoding failed.
    #[error("bech32 encode failed: {0}")]
    Bech32Encode(String),

    /// HRP (human-readable part) parsing failed during bech32 encoding.
    #[error("{0}")]
    InvalidHrp(String),
}