create skeleton for server from design

This commit is contained in:
2019-04-20 01:24:19 +02:00
parent 6f86302e06
commit 88fae2cba4
10 changed files with 277 additions and 245 deletions

View File

@ -0,0 +1,19 @@
// TODO: remove on implementation
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use crate::model::*;
pub struct ConvertConfig {
pub desired_size: (usize, usize),
}
pub fn generate_preview(
input: &[u8],
format: TextureFormat,
config: &ConvertConfig,
) -> ::image::ImageResult<Vec<u8>> {
unimplemented!()
}

View File

@ -0,0 +1,75 @@
// 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!();
}
}

View File

@ -0,0 +1,38 @@
// TODO: remove on implementation
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use crate::model::*;
pub struct Query {
filters: Vec<QueryFilterModifier>,
}
pub type QueryParserResult = Result<Query, QuerySyntaxError>;
pub enum QuerySyntaxError {
UnknownFilter,
}
impl Query {
pub fn parse(input: &[String]) -> QueryParserResult {
unimplemented!()
}
}
pub fn search(input: &[Texture], query: &Query) -> Vec<Texture> {
unimplemented!()
}
enum QueryFilterModifier {
None(QueryFilter),
Not(QueryFilter),
}
enum QueryFilter {
TagName(String),
InName(String),
MinResolution(usize),
BeforeDate { year: u16, month: u16, day: u16 },
}