Struct JSDB

Source
pub struct JSDB<Value> {
    pub databases: HashMap<String, Database<Value>>,
}
Expand description

JSDB: A lightweight, high-performance database API for Rust.

The JSDB crate provides a simple, database management system designed for ease of use and flexibility. It organizes data hierarchically with environments (JSDB), databases (Database), tables (Table), rows (Row), and columns. This structure supports generic data types, allowing developers to store various kinds of values.

§Features

  • Create and manage multiple databases within a single environment.
  • Support for generic value types in rows.
  • Simple API for adding and removing databases.

§Usage

The JSDB struct is the entry point for interacting with the database system. Use it to create an environment, add databases, and manage data.

§Examples

use jsdb::JSDB;
use jsdb::database::database::Database;

// Create a new JSDB environment
let mut project: JSDB<String> = JSDB::new();

// Create a database and add it to the environment
let db1 = Database::create_database();
project.add_database("my_database", db1);

// Remove a database
project.delete_database("my_database");

§Notes

  • This is an in-memory database, so data is not persisted to disk.
  • Ensure unique database names to avoid overwriting existing databases.

Fields§

§databases: HashMap<String, Database<Value>>

Implementations§

Source§

impl<Value> JSDB<Value>

Source

pub fn new() -> Self

Creates an empty environment for holding databases

Source

pub fn add_database(&mut self, name: &str, database: Database<Value>)

Adds database to the environment HashMap

Source

pub fn delete_database(&mut self, name: &str)

Removes database from the environment HashMap

Trait Implementations§

Source§

impl<Value: Debug> Debug for JSDB<Value>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Value> Freeze for JSDB<Value>

§

impl<Value> RefUnwindSafe for JSDB<Value>
where Value: RefUnwindSafe,

§

impl<Value> Send for JSDB<Value>
where Value: Send,

§

impl<Value> Sync for JSDB<Value>
where Value: Sync,

§

impl<Value> Unpin for JSDB<Value>
where Value: Unpin,

§

impl<Value> UnwindSafe for JSDB<Value>
where Value: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.