multisql/databases/memory/
mod.rs1mod auto_increment;
2mod base;
3mod mutable;
4
5use {
6 crate::{database::*, Row, Schema, Value},
7 serde::Serialize,
8 std::{
9 collections::{BTreeMap, HashMap},
10 fmt::Debug,
11 },
12 thiserror::Error,
13};
14
15#[derive(Error, Serialize, Debug, PartialEq)]
16pub enum MemoryDatabaseError {
17 #[error("table not found")]
18 TableNotFound,
19}
20
21#[derive(Default, Clone)]
22pub struct MemoryDatabase {
23 tables: HashMap<String, Schema>,
24 data: HashMap<String, HashMap<Value, Row>>,
25 indexes: HashMap<String, HashMap<String, BTreeMap<Value, Value>>>,
26}
27
28impl DBFull for MemoryDatabase {}
29
30impl MemoryDatabase {
31 pub fn new() -> Self {
32 Self::default()
33 }
34}