Added FileData trait to Databases.

This commit is contained in:
2023-01-22 14:15:34 -05:00
parent 878e5277bf
commit 6e6de135ef
2 changed files with 118 additions and 2 deletions

View File

@ -12,13 +12,18 @@ use error::DBError;
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use std::{
collections::HashMap,
fmt, str,
fmt, slice, str,
time::{Duration, Instant},
};
const DATA: &str = "data";
const ENTRY: &str = "databases";
trait FileData<F> {
fn to_bytes(&self) -> Vec<u8>;
fn from_bytes(data: &mut slice::Iter<u8>) -> Result<F, DBError>;
}
#[derive(Clone)]
pub enum CacheType {
Raw(String),