lcpc_2d/
macros.rs

1// Copyright 2021 Riad S. Wahby <rsw@cs.stanford.edu>
2//
3// This file is part of lcpc-2d, which is part of lcpc.
4//
5// Licensed under the Apache License, Version 2.0 (see
6// LICENSE or https://www.apache.org/licenses/LICENSE-2.0).
7// This file may not be copied, modified, or distributed
8// except according to those terms.
9
10/// Define domain separation labels for an LcEncoding trait implementation
11///
12/// Use this to conveniently define the LABEL_xx values for domain separation,
13/// e.g.:
14///
15/// ```ignore
16/// impl LcEncoding for ... {
17///     ...
18///
19///     def_labels!(my_encoding_name);
20///
21///     ...
22/// }
23///
24/// ```
25///
26/// Note that the argument may only contain alphanumerics and underscores,
27/// and cannot be just an underscore (same rules as Rust identifiers).
28#[macro_export]
29macro_rules! def_labels {
30    ($l:ident) => {
31        const LABEL_DT: &'static [u8] = b"$l//DT";
32        const LABEL_PR: &'static [u8] = b"$l//PR";
33        const LABEL_PE: &'static [u8] = b"$l//PE";
34        const LABEL_CO: &'static [u8] = b"$l//CO";
35    };
36}