//! # WebSocket routes //! //! @author Pierre Hubert use crate::data::error::Res; use crate::data::user_ws_request_handler::WsRequestHandler; pub type WsRequestProcess = Box Res>; /// WebSocket route pub struct WsRoute { pub route: String, pub handler: WsRequestProcess, } impl WsRoute { pub fn new(route: &str, handler: H) -> WsRoute where H: 'static + Fn(&mut WsRequestHandler) -> Res { WsRoute { route: route.to_string(), handler: Box::new(handler), } } } /// Get the list of available WebSocket routes pub fn get_ws_routes() -> Vec { vec![] } /// Search for a route pub fn find_ws_route(uri: &str) -> Option { get_ws_routes().into_iter().find(|r| r.route == uri) }