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}; #[derive(Clone, Debug)]
use std::slice;
#[derive(Clone)]
pub struct Database; pub struct Database;
impl Database { impl Database {
pub fn new() -> Self { fn new() -> Self {
Self Self {}
} }
} }
impl FileData<Self> for Database { #[cfg(test)]
fn to_bytes(&self) -> Vec<u8> { mod dbase {
let output = Vec::new(); use super::*;
output
}
fn from_bytes(_data: &mut slice::Iter<u8>) -> Result<Self, DBError> { #[test]
Ok(Self {}) fn create_new() {
} Database::new();
}
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,4 +1,5 @@
mod cache; mod cache;
mod database;
mod error; mod error;
mod store; mod store;
@ -8,6 +9,7 @@ use async_std::{
task::spawn, task::spawn,
}; };
use cache::Cache; use cache::Cache;
use database::Database;
use error::{ErrorCode, MTTError}; use error::{ErrorCode, MTTError};
use store::Store; use store::Store;

View File

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