ruma icon indicating copy to clipboard operation
ruma copied to clipboard

Allow streaming binary http bodies

Open jplatte opened this issue 4 years ago • 10 comments

Related: #603

jplatte avatar Jun 04 '21 10:06 jplatte

How would this work? Would we allow streaming on only some request/response types, or will we switch to a Into<&[u8]>-able streaming type?

ShadowJonathan avatar Jun 04 '21 11:06 ShadowJonathan

Useful for https://gitlab.com/famedly/conduit/-/issues/93

HKalbasi avatar Jun 04 '21 11:06 HKalbasi

I have only a very rough idea of how this could work in my head. It would involve making the request / response traits generic, rather than having them contain a generic method, making the raw_body request / response types generic over the raw_body type and using different bounds for their request / response trait implementations. I might be able to work on this over the weekend.

jplatte avatar Jun 04 '21 11:06 jplatte

If you don't want to do this in ruma, it's probably rather simple for conduit to not use ruma on that endpoint.

timokoesters avatar Jun 08 '21 07:06 timokoesters

I definitely want to do this in Ruma, but don't know when I'll get to it or how hard it will be. If sbd. wants to help, let's discuss the implementation on #ruma-dev.

jplatte avatar Jun 08 '21 08:06 jplatte

Rocket's code might be worth looking at: https://api.rocket.rs/v0.5-rc/rocket/fs/struct.NamedFile.html

timokoesters avatar Jun 09 '21 17:06 timokoesters

The hard part is not how to stream http bodies, the hard part is integrating this with ruma-api's request / response traits.

jplatte avatar Jun 09 '21 17:06 jplatte

Is an specific stream-able type too restrictive? It should be generic?

HKalbasi avatar Jun 09 '21 17:06 HKalbasi

I think it should be generic, so users can choose between different async File types or in-memory types such as hyper::Body / reqwest::Body.

jplatte avatar Jun 09 '21 18:06 jplatte