noatun 0.1.3

Noatun is an in-process, distributed database with materialized view support.
Documentation
#[cfg(not(target_arch = "wasm32"))]
use crate::platform_specific::get_boot_time;
#[cfg(not(target_arch = "wasm32"))]
use crate::sha2_helper::sha2;
#[cfg(not(target_arch = "wasm32"))]
use std::sync::OnceLock;

#[cfg(not(target_arch = "wasm32"))]
static BOOT_CHECKSUM: OnceLock<[u8; 16]> = OnceLock::new();

/// Returns a unique identifier that identifies this current boot.
/// After a reboot of the operating system, due to power-loss or otherwise,
/// this method will return a different value.
///
/// We use this to determine if unflushed memory mapped data might have been lost
pub(crate) fn get_boot_checksum() -> [u8; 16] {
    #[cfg(not(target_arch = "wasm32"))]
    {
        *BOOT_CHECKSUM.get_or_init(|| {
            let boot_time = get_boot_time();
            sha2(boot_time.as_bytes())
        })
    }
    #[cfg(target_arch = "wasm32")]
    {
        [0u8; 16]
    }
}