76 lines
1.7 KiB
Rust
76 lines
1.7 KiB
Rust
|
// TODO: remove on implementation
|
||
|
#![allow(unused_imports)]
|
||
|
#![allow(unused_variables)]
|
||
|
#![allow(dead_code)]
|
||
|
|
||
|
use crate::model::*;
|
||
|
|
||
|
use std::collections::HashMap;
|
||
|
use std::io;
|
||
|
use std::path::{Path, PathBuf};
|
||
|
use std::sync::Arc;
|
||
|
|
||
|
pub use self::search::Query;
|
||
|
mod search;
|
||
|
mod image_convert;
|
||
|
|
||
|
pub type TextureFileResult = Result< Arc<Vec<u8>> , TextureFileError>;
|
||
|
pub enum TextureFileError {
|
||
|
NotFound,
|
||
|
IoError(io::Error),
|
||
|
ImageError(::image::ImageError),
|
||
|
}
|
||
|
|
||
|
pub struct DataStore {
|
||
|
// private attributes
|
||
|
// may change
|
||
|
data_dir: PathBuf,
|
||
|
texture: Vec<Texture>,
|
||
|
preview_cache: HashMap<(TextureFormat, Sha256), Arc<Vec<u8>>>,
|
||
|
}
|
||
|
|
||
|
impl DataStore {
|
||
|
pub fn new(path: &Path) -> io::Result<DataStore> {
|
||
|
unimplemented!()
|
||
|
}
|
||
|
|
||
|
pub fn garbage_collect(&mut self) -> io::Result<()> {
|
||
|
unimplemented!()
|
||
|
}
|
||
|
|
||
|
pub fn query(&mut self, query: &self::search::Query) -> Vec<Texture> {
|
||
|
unimplemented!();
|
||
|
// calls self::search::search(... )
|
||
|
}
|
||
|
|
||
|
/// returns true if successful
|
||
|
pub fn delete(&mut self, tex: &Texture) -> bool {
|
||
|
unimplemented!();
|
||
|
}
|
||
|
|
||
|
pub fn insert(&mut self, tex: Texture) -> bool {
|
||
|
unimplemented!();
|
||
|
}
|
||
|
|
||
|
pub fn by_name<'a>(&'a self, name: &str) -> Option<&'a Texture> {
|
||
|
unimplemented!();
|
||
|
}
|
||
|
|
||
|
pub fn by_id<'a, 'b>(&'a self, id: &'b str) -> Option<&'a Texture> {
|
||
|
unimplemented!();
|
||
|
}
|
||
|
|
||
|
pub fn has_hash(&self, hash: &Sha256) -> bool {
|
||
|
unimplemented!();
|
||
|
}
|
||
|
|
||
|
pub fn get_texture_file(&mut self, hash: &Sha256) -> TextureFileResult {
|
||
|
unimplemented!();
|
||
|
}
|
||
|
|
||
|
pub fn get_texture_preview(&mut self, hash: &Sha256) -> TextureFileResult {
|
||
|
unimplemented!();
|
||
|
}
|
||
|
}
|
||
|
|