From 30ea8d978ca082a932a040278c23a71d7eb8c917 Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Sat, 3 Jun 2023 15:27:26 -0400 Subject: [PATCH] Setup for data. --- src/morethantext/mod.rs | 34 +++++++++++++++++++++++++++++----- src/morethantext/store.rs | 5 +++-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/morethantext/mod.rs b/src/morethantext/mod.rs index 5e77c20..e18b4e6 100644 --- a/src/morethantext/mod.rs +++ b/src/morethantext/mod.rs @@ -11,22 +11,42 @@ use cache::Cache; use error::{ErrorCode, MTTError}; use store::Store; +const ENTRY: &str = "EntryPoint"; + #[derive(Clone, Debug)] -struct Data { - id: String, +struct Data { + id: Option, + data: Option, +} + +impl Data { + fn from_id(id: S) -> Self + where + S: Into, + { + Self { + id: Some(id.into()), + data: None, + } + } } #[derive(Clone)] pub struct MoreThanText { to_cache: Sender, + entry: Data, } impl MoreThanText { fn new(to_cache: Sender) -> Self { - Self { to_cache: to_cache } + Self { + to_cache: to_cache, + entry: Data::from_id(ENTRY), + } } - async fn session(&self) { + async fn session(&self) -> Store { + Store::new() } } @@ -39,7 +59,11 @@ mod mtt { async fn create_new() { let dir = tempdir().unwrap(); let mtt = start_db(dir.path()).await.unwrap(); - mtt.session().await; + assert_eq!(mtt.entry.id, Some(ENTRY.to_string())); + assert!(mtt.entry.data.is_none()); + let store = mtt.session().await; + let expected: Vec = Vec::new(); + assert_eq!(store.list(), expected); } } diff --git a/src/morethantext/store.rs b/src/morethantext/store.rs index 1f95a27..26dcb3a 100644 --- a/src/morethantext/store.rs +++ b/src/morethantext/store.rs @@ -1,11 +1,12 @@ +#[derive(Clone)] pub struct Store; impl Store { - fn new() -> Self { + pub fn new() -> Self { Self {} } - fn list(&self) -> Vec { + pub fn list(&self) -> Vec { Vec::new() } }