add implementation for FromFormValue for SafeString

thanks again to @pwoolcoc for this!
This commit is contained in:
Igor Galić 2018-09-14 18:26:42 +02:00
parent 65e213309b
commit 0897088aa5
No known key found for this signature in database
GPG Key ID: ACFEFF7F6A123A86

View File

@ -101,3 +101,17 @@ impl AsRef<str> for SafeString {
&self.value
}
}
use rocket::request::FromFormValue;
use rocket::http::RawStr;
impl<'v> FromFormValue<'v> for SafeString {
type Error = &'v RawStr;
fn from_form_value(form_value: &'v RawStr) -> Result<SafeString, &'v RawStr> {
let val = String::from_form_value(form_value)?;
Ok(SafeString {
value: val,
})
}
}