trying to make it so that a tuple and anything that implements the Serialize
trait can be converted into a response
impl From<(u16, &'static str)> for Response {
fn from(tuple: (u16, &'static str)) -> Response {
res()
.with_header(ContentType::plaintext())
.with_status(toStatusCode(tuple.0))
.with_body(tuple.1)
}
}
impl<T: Serialize> From<T> for Response {
fn from(json: T) -> Response {
res()
.with_header(ContentType::json())
.with_status(toStatusCode(200))
.with_body(to_string(&json).unwrap())
}
}
not sure why I'm getting a conflicting requirements error.
➜ cargo build
Compiling arc-reactor v0.1.0 (file:///home/seun/Projects/arc-reactor)
error[E0119]: conflicting implementations of trait `std::convert::From<(u16, &'static str)>` for type `core::response::Response`:
--> src/proto/convert.rs:23:1
|
14 | impl From<(u16, &'static str)> for Response {
| ------------------------------------------- first implementation here
...
23 | impl<T: Serialize> From<T> for Response {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `core::response::Response`
error: aborting due to previous error
error: Could not compile `arc-reactor`.
To learn more, run the command again with --verbose.