Compare commits

...

2 Commits

Author SHA1 Message Date
a23b5d467e Setup store to hold databases. 2023-06-22 11:08:40 -04:00
c8b93d9922 Moved old database code. 2023-06-22 10:35:05 -04:00
4 changed files with 56 additions and 29 deletions

View File

@ -0,0 +1,36 @@
use super::{DBError, FileData, SessionData};
use std::slice;
#[derive(Clone)]
pub struct Database;
impl Database {
pub fn new() -> Self {
Self
}
}
impl FileData<Self> for Database {
fn to_bytes(&self) -> Vec<u8> {
let output = Vec::new();
output
}
fn from_bytes(_data: &mut slice::Iter<u8>) -> Result<Self, DBError> {
Ok(Self {})
}
}
impl SessionData for Database {
fn add(&mut self, _key: &str, _value: &str, _data: &str) -> Result<Vec<String>, DBError> {
Ok(Vec::new())
}
fn eq(&self, _key: &str, _value: &str) -> Result<Vec<String>, DBError> {
Ok(Vec::new())
}
fn list(&self, _keys: Vec<&str>) -> Result<Vec<String>, DBError> {
Ok(Vec::new())
}
}

View File

@ -1,36 +1,18 @@
use super::{DBError, FileData, SessionData};
use std::slice;
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct Database;
impl Database {
pub fn new() -> Self {
Self
fn new() -> Self {
Self {}
}
}
impl FileData<Self> for Database {
fn to_bytes(&self) -> Vec<u8> {
let output = Vec::new();
output
}
#[cfg(test)]
mod dbase {
use super::*;
fn from_bytes(_data: &mut slice::Iter<u8>) -> Result<Self, DBError> {
Ok(Self {})
}
}
impl SessionData for Database {
fn add(&mut self, _key: &str, _value: &str, _data: &str) -> Result<Vec<String>, DBError> {
Ok(Vec::new())
}
fn eq(&self, _key: &str, _value: &str) -> Result<Vec<String>, DBError> {
Ok(Vec::new())
}
fn list(&self, _keys: Vec<&str>) -> Result<Vec<String>, DBError> {
Ok(Vec::new())
#[test]
fn create_new() {
Database::new();
}
}

View File

@ -1,4 +1,5 @@
mod cache;
mod database;
mod error;
mod store;
@ -8,6 +9,7 @@ use async_std::{
task::spawn,
};
use cache::Cache;
use database::Database;
use error::{ErrorCode, MTTError};
use store::Store;

View File

@ -1,9 +1,16 @@
use super::{Data, Database};
use std::collections::HashMap;
#[derive(Clone, Debug)]
pub struct Store;
pub struct Store {
data: HashMap<String, Data<Database>>,
}
impl Store {
pub fn new() -> Self {
Self {}
Self {
data: HashMap::new(),
}
}
pub fn list(&self) -> Vec<String> {