csv_lib/models/
platform_info.rs

1
2
3#[derive(Debug)]
4/// ## PlatformInfo struct
5/// - A internal struct, that collect info about the flatform were the code is running.
6/// - Set, which function is used, according the features.
7pub struct PlatformInfo{
8    pub supports_neon: bool,
9    pub supports_avx2: bool,
10    pub supports_memcacher3 : bool,
11}
12
13/// ## Default implement for PlatformInfo
14/// - By default, disable NEON/ AVX2 support, to improve compatibility.
15impl Default for PlatformInfo {
16    fn default() -> Self {
17        Self {
18            supports_avx2 : false,
19            supports_memcacher3: true,
20            supports_neon: false,
21        }
22    }
23}
24
25
26impl PlatformInfo {
27    /// ## New Function:
28    /// - Creates a new instance of `PlatformInfo`, and check of the mapped features are available.
29    pub fn new() -> Self{
30        let mut plat = Self::default();
31        #[cfg(target_arch = "x86_64")]
32        {
33            if is_x86_feature_detected!("avx2") {
34                plat.supports_avx2 = true;
35            }
36        }
37        #[cfg(target_arch = "aarch64")]
38        {
39            plat.supports_neon = true;
40        }
41        plat
42    }
43}
44
45
46