Setup for data.
This commit is contained in:
		@@ -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<D> {
 | 
			
		||||
    id: Option<String>,
 | 
			
		||||
    data: Option<D>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<D> Data<D> {
 | 
			
		||||
    fn from_id<S>(id: S) -> Self
 | 
			
		||||
    where
 | 
			
		||||
        S: Into<String>,
 | 
			
		||||
    {
 | 
			
		||||
        Self {
 | 
			
		||||
            id: Some(id.into()),
 | 
			
		||||
            data: None,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Clone)]
 | 
			
		||||
pub struct MoreThanText {
 | 
			
		||||
    to_cache: Sender<String>,
 | 
			
		||||
    entry: Data<Store>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl MoreThanText {
 | 
			
		||||
    fn new(to_cache: Sender<String>) -> 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<String> = Vec::new();
 | 
			
		||||
        assert_eq!(store.list(), expected);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,12 @@
 | 
			
		||||
#[derive(Clone)]
 | 
			
		||||
pub struct Store;
 | 
			
		||||
 | 
			
		||||
impl Store {
 | 
			
		||||
    fn new() -> Self {
 | 
			
		||||
    pub fn new() -> Self {
 | 
			
		||||
        Self {}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn list(&self) -> Vec<String> {
 | 
			
		||||
    pub fn list(&self) -> Vec<String> {
 | 
			
		||||
        Vec::new()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user