2022-12-21 19:09:59 -08:00
|
|
|
use crate::message_types::{UIRequest};
|
2022-12-18 18:26:13 -08:00
|
|
|
|
2022-12-21 19:09:59 -08:00
|
|
|
/// Pass a
|
2022-12-18 21:07:33 -08:00
|
|
|
pub fn handle_request(socket_message: String) -> Result<UIRequest, serde_json::Error> {
|
2022-12-18 18:26:13 -08:00
|
|
|
println!("Recieved a socket message: {}", socket_message);
|
2022-12-18 21:07:33 -08:00
|
|
|
let request: UIRequest = serde_json::from_str(&socket_message)?;
|
2022-12-21 19:09:59 -08:00
|
|
|
|
2022-12-18 21:07:33 -08:00
|
|
|
Ok(request)
|
2022-12-18 18:26:13 -08:00
|
|
|
}
|
2022-12-21 19:09:59 -08:00
|
|
|
|
|
|
|
fn sanitize_input(input: UIRequest) -> Result<UIRequest, ()> {
|
|
|
|
// if UIRequest is a search string, make sure it is
|
|
|
|
// not empty
|
|
|
|
// has no %, this is a fuzzy search, This program handles that, maybe replace * with %
|
|
|
|
// has a type of request (e.g. "title search: value")
|
|
|
|
Ok(UIRequest::Pause)
|
|
|
|
}
|