rsmp4decrypt 0.1.0

Rust bindings and a CLI for Bento4 mp4decrypt
Documentation
use thiserror::Error;

/// Errors returned by the public Rust API and CLI.
#[derive(Debug, Error)]
pub enum Error {
    /// Input or output buffers cannot be represented with Bento4's 32-bit size limits.
    #[error("data too large (maximum supported {0} bytes)")]
    DataTooLarge(u32),

    /// Bento4 did not create a decryptor context.
    #[error("Bento4 failed to create a decryptor context")]
    ContextCreationFailed,

    /// Bento4 returned an error while parsing or decrypting a file or fragment.
    #[error("failed to decrypt media with Bento4 error code {0}")]
    DecryptionFailed(i32),

    /// A hexadecimal KID or key had the wrong size.
    #[error("invalid hex value '{input}': {message}")]
    InvalidHex { input: String, message: String },

    /// A `--key` value did not follow the expected `<id>:<key>` format.
    #[error("invalid --key spec '{input}': {message}")]
    InvalidKeySpec { input: String, message: String },

    /// A path could not be passed through the C interface because it contains a NUL byte.
    #[error("path contains an interior NUL byte: {0}")]
    InvalidPath(#[from] std::ffi::NulError),

    /// The builder was finalized without any decryption keys.
    #[error("at least one decryption key must be configured")]
    NoKeys,

    /// A hexadecimal KID or key could not be decoded.
    #[error("hex decode error: {0}")]
    HexDecode(#[from] hex::FromHexError),
}