Crate offline_first_core

Source
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:

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.