diff --git a/src/util.rs b/src/util.rs index 8c4efca8..4a8af5e9 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,13 +1,12 @@ // // Web Headers and caching // -use std::{collections::HashMap, io::Cursor, ops::Deref, path::Path}; +use std::{collections::HashMap, io::Cursor, path::Path}; use num_traits::ToPrimitive; use rocket::{ fairing::{Fairing, Info, Kind}, http::{ContentType, Header, HeaderMap, Method, Status}, - request::FromParam, response::{self, Responder}, Data, Orbit, Request, Response, Rocket, }; @@ -223,42 +222,6 @@ impl<'r, R: 'r + Responder<'r, 'static> + Send> Responder<'r, 'static> for Cache } } -pub struct SafeString(String); - -impl fmt::Display for SafeString { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.0.fmt(f) - } -} - -impl Deref for SafeString { - type Target = String; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl AsRef for SafeString { - #[inline] - fn as_ref(&self) -> &Path { - Path::new(&self.0) - } -} - -impl<'r> FromParam<'r> for SafeString { - type Error = (); - - #[inline(always)] - fn from_param(param: &'r str) -> Result { - if param.chars().all(|c| matches!(c, 'a'..='z' | 'A'..='Z' |'0'..='9' | '-')) { - Ok(SafeString(param.to_string())) - } else { - Err(()) - } - } -} - // Log all the routes from the main paths list, and the attachments endpoint // Effectively ignores, any static file route, and the alive endpoint const LOGGED_ROUTES: [&str; 7] = ["/api", "/admin", "/identity", "/icons", "/attachments", "/events", "/notifications"];