Crate gddb

source · []
Expand description


GDDB is a superfast in-memory database designed for use in Godot.

This database aims to provide an easy frontend to an efficient in-memory database, that can be saved and reloaded.

GDDB saves a Godot dictionary and provides an interface to create, update, retrieve (either single results or all items matching the search) and destroy records.

GDDB started as a fork of TinyDB with added functionality and a Godot wrapper.

Rust Example 🚀

An example of utilising GDDB within your Rust library.

use serde::{Serialize, Deserialize};
use gddb::Database;

#[derive(Debug, Eq, PartialEq, Hash, Serialize, Deserialize, Clone)]
struct PlayerStruct {
    name: String

fn main() {
    let player = PlayerStruct { name: "Joe Bloggs".into() };
    let mut db = Database::new("GAME", None, false);


    let results = db.find(|s: &PlayerStruct| &, "Joe Bloggs".into());

    assert_eq!(results.unwrap(), &player);


Simply add the following to your Cargo.toml file:

gddb = "0.3.0"

Implementation notes

  • This database does not save 2 duplicated items, either ignoring or raising an error depending on end-user preference.
  • This project is not intended to be used inside of any critical systems due to the nature of dumping/recovery. If you are using this crate as a temporary and in-memory only database, it should preform at a reasonable speed (as it uses HashSet underneath).

Essential operations

Some commonly-used operations for the Database structure.

Create databaseDatabase::new
Create database from fileDatabase::from
Load database or create if non-existantDatabase::auto_from
Query all matching itemsDatabase::query
Query for itemDatabase::find
Contains specific itemDatabase::contains
Update/replace itemDatabase::update
Delete itemDatabase::destroy
Dump databaseDatabase::dump_db


Contains various items related to errors inside of GDDB.