k2hash_sys/
lib.rs

1#[allow(non_camel_case_types)]
2
3extern crate libc;
4use libc::{c_int, c_char, c_uchar, size_t, uint64_t};
5
6pub type k2h_h = uint64_t;
7pub const DEFAULT_MASK_BITCOUNT: c_int = 8;
8pub const DEFAULT_COLLISION_MASK_BITCOUNT: c_int = 4;
9pub const DEFAULT_MAX_ELEMENT_CNT: c_int = 32;
10pub const MIN_PAGE_SIZE: size_t = 128;
11
12#[link(name = "k2hash")]
13extern "C" {
14    pub fn k2h_open(filepath: *const c_char, readonly: bool, removefile: bool, 
15					fullmap: bool, maskbitcnt: c_int, cmaskbitcnt: c_int,
16					maxelementcnt: c_int, pagesize: size_t) -> k2h_h;
17
18	pub fn k2h_close(handle: k2h_h) -> bool;
19
20    pub fn k2h_get_value(handle: k2h_h, pkey: *const c_uchar, keylength: size_t,
21                         ppval: *mut *mut u8, pvallength: *mut size_t) -> bool;
22
23    pub fn k2h_get_str_direct_value(handle: k2h_h, pkey: *const c_char) -> *const c_uchar;
24
25    pub fn k2h_set_value(handle: k2h_h, pkey: *const c_uchar, keylength: size_t,
26						 pval: *const u8, vallength: size_t) -> bool;
27
28    pub fn k2h_set_str_value(handle: k2h_h, pkey: *const c_char, pval: *const c_char) -> bool;
29}