byte-array-ops 0.4.0

A no_std-compatible library for security-by-default byte array operations. Includes automatic memory zeroization, constant-time utilities, multiple input formats (hex, binary, UTF-8), bitwise operations, and comprehensive type conversions with minimal dependencies.
Documentation
//! Display and Debug implementations for ByteArray
//!
//! Formatting is restricted to prevent accidental data leakage

use crate::model::ByteArray;
use core::fmt::{Debug, Display, Formatter};

impl Display for ByteArray {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        #[cfg(debug_assertions)] // we show the data only when we are in debug releases
        return self.bytes.fmt(f);
        #[cfg(not(debug_assertions))]
        // when in release mode we truncate and only show bytearray length
        return write!(f, "ByteArray length: {}", self.len());
    }
}

/// Debug implementation delegates to Display for consistent behavior
impl Debug for ByteArray {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        <ByteArray as Display>::fmt(self, f)
    }
}