amebazii

Macro is_valid_data

Source
macro_rules! is_valid_data {
    ($key:expr) => { ... };
}
Expand description

Checks if the given data is valid by ensuring none of the bytes are equal to 0xFF.

This macro checks if all elements in the provided data are non-0xFF.

§Parameters

  • $key: The key or data collection to check, which must be an iterable type (e.g., a slice or array).

§Returns

  • true if no byte in the data is 0xFF.
  • false if any byte in the data is 0xFF.

§Example

let key = [0x01, 0x02, 0x03, 0x04, 0x05];
assert!(is_valid_data!(key)); // All bytes are non-0xFF, so it's valid.

let invalid_key = [0xFF, 0xFF, 0xFF, 0xFF];
assert!(!is_valid_data!(invalid_key)); // Contains only 0xFF bytes, so it's invalid.