Created
February 26, 2020 22:20
-
-
Save richo/4570549a0e016384ced4700c6e223e83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::{self, Read}; | |
use protobuf; | |
use rocket::{Request, Data, Outcome::*}; | |
use rocket::data::{FromDataSimple, Outcome, Transform, Transformed}; | |
use rocket::http::Status; | |
// We have to involve a local trait for *reasons* | |
trait FromDataMarker {} | |
impl<T> FromDataMarker for T where T: protobuf::Message {} | |
impl<T> FromDataSimple for T | |
where T: protobuf::Message + FromDataMarker { | |
type Error = (); | |
fn from_data(req: &Request, data: Data) -> Outcome<T, String> { | |
let mut object = T::new(); | |
// object.merge_from(data); | |
Success(object) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
^ type parameter
T
must be used as the type parameter for some local type