unqlite-sys

Crates.iounqlite-sys
lib.rsunqlite-sys
version1.1.0
sourcesrc
created_at2015-12-21 09:09:36.835019
updated_at2017-06-12 05:45:49.124895
descriptionRust `unqlite` bindings.
homepagehttps://github.com/zitsen/unqlite-sys.rs
repositoryhttps://github.com/zitsen/unqlite-sys.rs.git
max_upload_size
id3719
size2,038,662
Linhe Huo (zitsen)

documentation

http://zitsen.github.io/unqlite-sys.rs

README

unqlite-sys

Rust bindings for UnQlite library.

travis-badge release-badge downloads docs-badge license-badge

As its official site says, UnQlite is

An Embeddable NoSQL Database Engine.

Please see UnQLite C/C++ API Reference for full API documents.

Usage

This crate provides several features for UnQlite compile-time options:

  • enable-threads: equivalent to UNQLITE_ENABLE_THREADS enabled.
  • jx9-disable-builtin-func: equivalent to JX9_DISABLE_BUILTIN_FUNC enabled.
  • jx9-enable-math-fuc: equivalent to JX9_ENABLE_MATH_FUNC enabled.
  • jx9-disable-disk-io: equivalent to JX9_DISABLE_DISK_IO enabled.
  • enable-jx9-hash-io: equivalent to UNQLITE_ENABLE_JX9_HASH_IO enabled.

To provide the same default behavior as original C does, non of the features is enabled by default. When you want some features, such as enable-threads, just config in Cargo.toml:

[dependencies.unqlite-sys]
version = "0.3.0"
features = [ "enable-threads" ]

For multiple features just add them in toml features array.

Threadsafe

Note that even "enable-threads" is featured in your crate, it's not meant that your code is threadsafe.

When UnQLite has been compiled with threading support then the threading mode can be altered at run-time using the unqlite_lib_config() interface together with one of these verbs:

UNQLITE_LIB_CONFIG_THREAD_LEVEL_SINGLE

UNQLITE_LIB_CONFIG_THREAD_LEVEL_MULTI

Platforms others than Windows and UNIX systems must install their own mutex subsystem via unqlite_lib_config() with a configuration verb set to UNQLITE_LIB_CONFIG_USER_MUTEX. Otherwise the library is not threadsafe.

Note that you must link UnQLite with the POSIX threads library under UNIX systems (i.e: -lpthread).

To use in multithread cases, that is threadsafe, you may use like this:

extern crate unqlite_sys as ffi;
use ffi::constants as ffic;

fn main() {
    unsafe {
        ffi::unqlite_lib_config(ffic::UNQLITE_LIB_CONFIG_THREAD_LEVEL_MULTI);
        ffi::unqlite_lib_init();
        assert_eq!(ffi::unqlite_lib_is_threadsafe(), 1);

        // do stuff ...

    }
}
Commit count: 41

cargo fmt