pub struct UnQLite { /* private fields */ }
Expand description
UnQLite database entry point.
UnQLite support both in-memory and on-disk database. There’s several constructors:
Constructor | Meaning |
---|---|
create_in_memory | Create a private, in-memory database. |
create_temp | Create a private, temporary on-disk database. |
create | Create if not exists, otherwise, open as read-write. |
open_mmap | Obtain a read-only memory view of the whole database. |
open_readonly | Open the database in a read-only mode. |
Implementations§
Source§impl UnQLite
impl UnQLite
Sourcepub fn create<P: AsRef<str>>(filename: P) -> UnQLite
pub fn create<P: AsRef<str>>(filename: P) -> UnQLite
Create UnQLite database as filename
.
By default, the database is created in read-write mode.
§Panics
Will panic if failed in creating.
§Example
ⓘ
let _ = UnQLite::create("test.db");
§C
unqlite *pDb;
// on-disk database
rc = unqlite_open(&pDb,"test.db",UNQLITE_OPEN_CREATE);
// in-memory database
rc = unqlite_open(&pDb, ":mem:", UNQLITE_OPEN_MEM);
Sourcepub fn create_in_memory() -> UnQLite
pub fn create_in_memory() -> UnQLite
Sourcepub fn create_temp() -> UnQLite
pub fn create_temp() -> UnQLite
Sourcepub fn open_readonly<P: AsRef<str>>(filename: P) -> UnQLite
pub fn open_readonly<P: AsRef<str>>(filename: P) -> UnQLite
Trait Implementations§
Source§impl Config for UnQLite
impl Config for UnQLite
Source§fn max_page_cache(self, max: u32) -> Self
fn max_page_cache(self, max: u32) -> Self
Maximum raw pages to cache in memory. Read more
Source§fn disable_auto_commit(self) -> Self
fn disable_auto_commit(self) -> Self
To diable automatically commit action. Read more
Source§fn kv_engine<S: Into<Vec<u8>>>(self, name: S) -> Self
fn kv_engine<S: Into<Vec<u8>>>(self, name: S) -> Self
Switch to another Key/Value storage engine. Read more
Source§fn err_log(&self) -> Option<String>
fn err_log(&self) -> Option<String>
The database error log is stored in an internal buffer. When something goes wrong during a
commit, rollback, store, append operation, a human-readable error message is generated to
help clients diagnose the problem. This option can be used to point to that buffer.
Source§fn jx9_err_log(&self) -> Option<String>
fn jx9_err_log(&self) -> Option<String>
When something goes wrong during compilation of the target Jx9 script due to an erroneous
Jx9 code, the compiler error log is redirected to an internal buffer. This option can be
used to point to that buffer.
Source§impl KV for UnQLite
Key-Value Store Interface
impl KV for UnQLite
Key-Value Store Interface
Source§fn kv_store<K: AsRef<[u8]>, V: AsRef<[u8]>>(
&self,
key: K,
value: V,
) -> Result<()>
fn kv_store<K: AsRef<[u8]>, V: AsRef<[u8]>>( &self, key: K, value: V, ) -> Result<()>
Store records in the database. Read more
Source§fn kv_append<K: AsRef<[u8]>, V: AsRef<[u8]>>(
&self,
key: K,
value: V,
) -> Result<()>
fn kv_append<K: AsRef<[u8]>, V: AsRef<[u8]>>( &self, key: K, value: V, ) -> Result<()>
Append data to a database record. Read more
Source§fn kv_delete<K: AsRef<[u8]>>(&self, key: K) -> Result<()>
fn kv_delete<K: AsRef<[u8]>>(&self, key: K) -> Result<()>
Remove a record from the database. Read more
Source§fn kv_fetch_length<K: AsRef<[u8]>>(&self, key: K) -> Result<i64>
fn kv_fetch_length<K: AsRef<[u8]>>(&self, key: K) -> Result<i64>
Fetch a record from the database and returns the length only
Source§fn kv_fetch<K: AsRef<[u8]>>(&self, key: K) -> Result<Vec<u8>>
fn kv_fetch<K: AsRef<[u8]>>(&self, key: K) -> Result<Vec<u8>>
Fetch a record from the database. Read more
Source§fn kv_fetch_callback<K: AsRef<[u8]>>(
&self,
key: K,
consumer: extern "C" fn(data: *const c_void, len: u32, user_data: *mut c_void) -> i32,
) -> Result<()>
fn kv_fetch_callback<K: AsRef<[u8]>>( &self, key: K, consumer: extern "C" fn(data: *const c_void, len: u32, user_data: *mut c_void) -> i32, ) -> Result<()>
Fetch a record from the database and invoke the supplied callback to consume its data.
Source§impl Transaction for UnQLite
impl Transaction for UnQLite
impl Send for UnQLite
impl Sync for UnQLite
Auto Trait Implementations§
impl Freeze for UnQLite
impl RefUnwindSafe for UnQLite
impl Unpin for UnQLite
impl UnwindSafe for UnQLite
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more