semaphore_rs_depth_config/
lib.rs

1#![allow(unused)]
2
3pub const fn get_supported_depth_count() -> usize {
4    let mut res = 0;
5    #[cfg(feature = "depth_16")]
6    {
7        res += 1;
8    }
9    #[cfg(feature = "depth_20")]
10    {
11        res += 1;
12    }
13    #[cfg(feature = "depth_30")]
14    {
15        res += 1;
16    }
17    res
18}
19
20#[allow(unused_assignments)]
21const fn gen_supported_depths() -> [usize; get_supported_depth_count()] {
22    let mut res = [0; get_supported_depth_count()];
23    let mut i = 0;
24    #[cfg(feature = "depth_16")]
25    {
26        res[i] = 16;
27        i += 1;
28    }
29    #[cfg(feature = "depth_20")]
30    {
31        res[i] = 20;
32        i += 1;
33    }
34    #[cfg(feature = "depth_30")]
35    {
36        res[i] = 30;
37        i += 1;
38    }
39    res
40}
41
42static SUPPORTED_DEPTHS: [usize; get_supported_depth_count()] = gen_supported_depths();
43
44pub fn get_supported_depths() -> &'static [usize] {
45    &SUPPORTED_DEPTHS
46}
47
48#[allow(unused_assignments)]
49pub const fn get_depth_index(depth: usize) -> Option<usize> {
50    let mut i = 0;
51
52    #[cfg(feature = "depth_16")]
53    {
54        if depth == 16 {
55            return Some(i);
56        }
57        i += 1;
58    }
59    #[cfg(feature = "depth_20")]
60    {
61        if depth == 20 {
62            return Some(i);
63        }
64        i += 1;
65    }
66    #[cfg(feature = "depth_30")]
67    {
68        if depth == 30 {
69            return Some(i);
70        }
71        i += 1;
72    }
73    None
74}