Macro hard::buffer[][src]

macro_rules! buffer {
    ($size:expr$(;)?) => { ... };
}
Expand description

Create a fixed-size anonymous buffer.

buffer!(Size) will initialise a new buffer of length Size bytes, returning Result<Buffer, HardError>.

The buffer will implement the following traits:

Example Usage

use hard::buffer;

// Create a 32-byte buffer
let mut some_buffer = buffer!(32).unwrap();
some_buffer.copy_from_slice(b"Copy this data into that buffer.");

let mut another_buffer = buffer!(32).unwrap();
some_buffer.copy_from_slice(b"We'll compare these two buffers.");

// This comparison is a constant-time equality-check of the contents of the two buffers
assert!(some_buffer != another_buffer);