implement glue code; Server is now startable

Server can now be used. All features except preview and gc should work.
This commit is contained in:
2019-05-07 22:43:14 +02:00
parent 5db62d4d08
commit d9d4f16c01
6 changed files with 44 additions and 12 deletions

View File

@ -1,6 +1,7 @@
use crate::model::*;
use crate::persistency::*;
use crate::protocol::*;
use crate::search::*;
use std::path::Path;
use std::sync::*;
@ -20,8 +21,14 @@ impl ServerState {
}
impl ProtocolHandler for ServerState {
fn query(&mut self, _query: &[String]) -> ProtocolResult<Vec<Texture>> {
unimplemented!()
fn query(&mut self, query: &[String]) -> ProtocolResult<Vec<Texture>> {
let q = Query::parse(query)
.map_err(|e| ProtocolError::BadRequest(format!("Invalid Query String: {:?}", e)))?;
let data_store = self.data_store.read().unwrap();
let mut textures = data_store.borrow_textures();
Ok(q.search(&mut textures))
}
fn get_texture_by_id(&mut self, id: &str) -> ProtocolResult<Option<Texture>> {