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

Cannot use rocket::response::stream::EventStream with okapi #52

Closed
g-murzik opened this issue Jul 15, 2021 · 3 comments
Closed

Cannot use rocket::response::stream::EventStream with okapi #52

g-murzik opened this issue Jul 15, 2021 · 3 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@g-murzik
Copy link

Hi,

First of all thanks for contributing okapi to the world!

I just tried to use the first EventStream example from the Rocket documentation decorated with #[openapi] and ran into the following error:

cargo build
   Compiling example v0.1.0 (...)
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
  --> src/main.rs:54:16
   |
54 | fn stream() -> EventStream![] {
   |                ^^^^^^^^^^^^^^
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

It compiles just fine when I use #[openapi(skip)] instead of #[openapi]. But do you have any idea how to make the example work with #[openapi]? Any help would be highly appreciated!

@ralpha
Copy link
Collaborator

ralpha commented Jul 16, 2021

The EventStream is new in Rocket 0.5.0 (I think). And I don't think this has been added yet (or even looked at).
So you are just breaking new ground at the moment. :)
I would have to look into this to know what the problem is (don't have much time at the moment), wrapping up some other projects atm.
But my best guess is that the macro syntax in that line is triggering something in the codegen of the code.
For now I think your best bet is to try and see if you can replace the EventStream![] with something.
But I don't know if this is even possible.
Maybe something along the lines of:

type EventStreamResponse = EventStream![];
#[get("/events")]
#[openapi]
fn events() -> EventStreamResponse {
    // ...
}

I don't know if this will work, but may be worth a try.

I'll leave this ticket open so we can properly fix this later.

@lrodriguez14
Copy link

Hello @ralpha,

Any updates about this?

Thanks!

@ralpha
Copy link
Collaborator

ralpha commented Feb 23, 2022

Any updates about this?

No, did not have the time to look into this at all. I'm open for other people to have a look at this and open a PR. Otherwise it will be a while because I don't have the time for this.

@ralpha ralpha closed this as completed in e686b44 Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants