1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2025, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.
use fmt;
/// A database hash key, used in FFI functions that require hashes.
/// This type requires no allocation and can be copied freely and
/// dropped without any additional overhead.
///
/// This is useful because it is the same size as 4 words which is equivalent
/// to 2 heap-allocated slices (pointer + length each), or 1.5 vectors (which
/// uses an extra word for allocation capacity) and it can be passed around
/// without needing to allocate or deallocate memory.
// Must use `repr(C)` instead of `repr(transparent)` to ensure it is a struct
// with one field instead of a type alias of an array of 32 element, which is
// necessary for FFI compatibility so that `HashKey` can be passed by value;
// otherwise, it would look like a pointer to an array of 32 bytes.
;