Expand description
§Offline First Core
A high-performance local storage library designed for FFI (Foreign Function Interface) integration with Flutter and other cross-platform applications. Built on LMDB (Lightning Memory-Mapped Database) for maximum stability and hot restart support.
§Features
- LMDB-based storage: Battle-tested database engine used by OpenLDAP and Bitcoin Core
- FFI-optimized: Designed specifically for Flutter integration with hot restart support
- ACID compliance: Full transaction support with data integrity guarantees
- Zero-copy reads: Memory-mapped access for optimal performance
- Safe error handling: No
unwrap()
calls in production code
§Quick Start
use offline_first_core::{create_db, push_data, get_by_id};
use std::ffi::CString;
// Create database instance
let db_name = CString::new("my_database").unwrap();
let db_state = create_db(db_name.as_ptr());
// Insert data
let json_data = CString::new(r#"{"id":"1","hash":"abc","data":{"key":"value"}}"#).unwrap();
let result = push_data(db_state, json_data.as_ptr());
§FFI Functions
This library exposes C-compatible functions for cross-language integration:
create_db
- Initialize database instancepush_data
- Insert new recordsget_by_id
- Retrieve records by IDget_all
- Retrieve all recordsupdate_data
- Update existing recordsdelete_by_id
- Delete records by IDclear_all_records
- Clear all database contentsreset_database
- Reset database to clean stateclose_database
- Explicit connection cleanup
Modules§
- local_
db_ model - Data model definitions for database storage.
- local_
db_ state - Database state management and operations.
Functions§
- clear_
all_ records - Clears all records from the database.
- close_
database - Explicitly closes the database connection.
- create_
db - Creates a new database instance with the specified name.
- delete_
by_ id - Deletes a record from the database by its ID.
- get_all
- Retrieves all records from the database.
- get_
by_ id - Retrieves a record from the database by its ID.
- push_
data - Inserts a new record into the database.
- reset_
database - Resets the database to a clean state with a new name.
- update_
data - Updates an existing record in the database.