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

Streaming protocol #1404

Open
rgbkrk opened this issue Oct 28, 2024 · 3 comments
Open

Streaming protocol #1404

rgbkrk opened this issue Oct 28, 2024 · 3 comments

Comments

@rgbkrk
Copy link

rgbkrk commented Oct 28, 2024

Is your feature request related to a problem? Please describe.

I'd love to have a way to push data to the webview in a streaming fashion, whether server sent events or websockets. This got discussed in #420, but is distinctly different as that issue was about asynchronously returning a singular response.

Describe the solution you'd like

Accept Response<Stream<Item = Vec<u8>>> in some manner.

Response (from http) can already accept a Stream

fn stream_response(
    _request: Request<Vec<u8>>,
) -> Result<Response<impl Stream<Item = Vec<u8>> + Send>> {
    let stream = futures::stream::iter(vec![
        "Hello ".as_bytes().to_vec(),
        "World".as_bytes().to_vec(),
    ]);

    Ok(Response::builder()
        .header("Content-Type", "text/plain")
        .status(200)
        .body(stream)
        .unwrap())
}

Where it goes awry is on response via the RequestAsyncResponder, which requires a Response<Into<Cow<'static, [u8]>>>.

image
@wadamek65
Copy link

Any updates on this? I'd be willing to give it a try to implement this as it seems it shouldn't be too complex of a change? @FabianLars

@FabianLars
Copy link
Member

No updates. As far as I know, nobody's working on it, I for one didn't even look into it at all.
I also have no idea how to implement this tbh

@wadamek65
Copy link

No updates. As far as I know, nobody's working on it, I for one didn't even look into it at all. I also have no idea how to implement this tbh

Alright, thanks for the response. I'll tinker a little bit and see if I can handle this alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants