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
30
31
32
33
34
35
36
#![no_std]
#![feature(const_if_match, const_loop, track_caller, proc_macro_hygiene)]
#![feature(asm)]

pub mod crc32;

#[doc(hidden)]
pub mod cpp;

#[doc(hidden)]
pub mod common;

#[doc(inline)]
pub use common::root::*;

#[doc(inline)]
pub use cpp::root::*;

// Find the hash40 of a given string
pub const fn hash40(string: &str) -> u64 {
    let bytes = string.as_bytes();

    ((bytes.len() as u64) << 32) + crc32::crc32(bytes) as u64
}

impl phx::Hash40 {
    pub fn new(string: &str) -> Self {
        Self { hash : hash40(string) }
    }

    pub fn new_raw(raw: u64) -> Self {
        Self { hash : raw }
    }
}

mod lua_const;