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
mod_use::mod_use![attr, compaction, log];

/// Several invariants that must be true for the format to work.
mod format_invariants {
    use crate::{
        consts::{HEADER_SIZE, INDEX_SIZE},
        formats::log::UuidIndex,
    };

    const _: () = {
        use std::mem::size_of;

        use crate::formats::log::Header;

        const fn assert_is_copy<T: Copy>() {
            _ = std::marker::PhantomData::<T>;
        }

        // The header must be `HEADER_SIZE` bytes.
        assert!(size_of::<Header>() == HEADER_SIZE);
        // The index must be `INDEX_SIZE` bytes.
        assert!(size_of::<UuidIndex>() == INDEX_SIZE);

        // The header must not hold other resources (vec etc.).
        assert_is_copy::<Header>();
        // The index must not hold other resources (vec etc.).
        assert_is_copy::<UuidIndex>();
    };
}