Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization issue when switching for serde packages > 1.0 #287

Closed
MrSpock opened this issue May 4, 2017 · 7 comments
Closed

Serialization issue when switching for serde packages > 1.0 #287

MrSpock opened this issue May 4, 2017 · 7 comments
Labels
question A question (converts to discussion)

Comments

@MrSpock
Copy link

MrSpock commented May 4, 2017

HI,
After updating serde* packages in my Cargo.toml to stable version (1.0.2) since some of other packages requires stable 1.0 version I'm getting errors for every handler with following error:

error[E0277]: the trait bound `pppoe::PPPoECredRequirements: serde::de::Deserialize` is not satisfied
   --> src/main.rs:141:1
    |
141 | #[post("/gencreds", data="<rcredparams>")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `serde::de::Deserialize` is not implemented for `nccrest::pppoe::PPPoECredRequirements`
    |
    = note: required because of the requirements on the impl of `rocket::data::FromData` for `rocket_contrib::JSON<nccrest::pppoe::PPPoECredRequirements>`
    = note: required because of the requirements on the impl of `rocket::data::FromData` for `std::result::Result<rocket_contrib::JSON<pppoe::PPPoECredRequirements>, rocket_contr
ib::Error>`

I can't use serde 0.9* since I'm getting errors similar to:

error: failed to select a version for `serde` (required by `*****`):
all possible versions conflict with previously selected versions of `serde`
  version 1.0.2 in use by **** v11.0.0
  possible versions to select: 0.9.14

Does rocket supports serde > 1.0 ??

@xentec
Copy link

xentec commented May 4, 2017

It does since 30fac32. You'll need to use master until v0.3.0 release.

@MrSpock
Copy link
Author

MrSpock commented May 4, 2017

After switching to master I'm getting following error:

    Updating git repository `https://github.com/SergioBenitez/Rocket`
    Updating registry `https://github.com/rust-lang/crates.io-index`
error: failed to select a version for `hyper` (required by `rocket`):
all possible versions conflict with previously selected versions of `hyper`
  version 0.10.9 in use by hyper v0.10.9
  possible versions to select: 0.10.8

I don't have hyper in my Cargo.toml

@MrSpock
Copy link
Author

MrSpock commented May 4, 2017

Switching rocket_contrib seems to solved issue:

[dependencies.rocket_contrib]
default-features = true
features = ["handlebars_templates"]
git = "https://github.com/SergioBenitez/Rocket"

But another appeared:


error[E0277]: the trait bound `&rocket::http::Cookies<'_>: rocket::request::FromRequest<'_, '_>` is not satisfied
  --> src/main.rs:83:1
   |
83 | #[post("/genpassword", data="<rdata>")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rocket::request::FromRequest<'_, '_>` is not implemented for `&rocket::http::Cookies<'_>`
   |
   = help: the following implementations were found:
             <rocket::http::Cookies<'a> as rocket::request::FromRequest<'a, 'r>>
   = note: required by `rocket::request::FromRequest::from_request`
error[E0277]: the trait bound `&str: rocket::request::FromParam<'_>` is not satisfied
   --> src/main.rs:154:1
    |
154 | #[get("/user/<user_id>")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rocket::request::FromParam<'_>` is not implemented for `&str`

@SergioBenitez
Copy link
Member

@MrSpock You've switched to master where there's no guarantee of API stability. In this case, you've noticed that &Cookies no longer implements FromRequest. Instead, you need to use Cookies directly.

@SergioBenitez SergioBenitez added the question A question (converts to discussion) label May 5, 2017
@SergioBenitez
Copy link
Member

Closing this out. Please do comment if your issue isn't resolved by my previous comment, @MrSpock!

@MrSpock
Copy link
Author

MrSpock commented May 10, 2017

Thanks for info. Cookie problem is solved but what about:
rocket::request::FromParam<'_>` is not implemented for `&str

I'm getting this for every req fn handler..

@SergioBenitez
Copy link
Member

SergioBenitez commented May 10, 2017

Again, this is a breaking change you're hitting. FromParam is no longer implemented for &str. See #43 for details. In short, use either String or &RawStr (from http::RawStr).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question (converts to discussion)
Projects
None yet
Development

No branches or pull requests

3 participants