seed icon indicating copy to clipboard operation
seed copied to clipboard

[proposal] Read or Iterator interface to seed::fetch::Response

Open platy opened this issue 4 years ago • 3 comments

Currently seed::fetch::Response has 3 interfaces: text, json, bytes. I'm working on something now which is fetching a large amount of non-text data, bytes can work but it is not ideal as it is unnecessarily allocating a large Vec in the wasm memory.

I propose to add an interface returning either a Read or an Iterator. Also, as either of these can fairly easily create a Vec<u8>, maybe we can replace the existing bytes.

I will try to come up with a function today, but am also wondering what others think.

platy avatar Apr 22 '20 11:04 platy

I (and I think the most users) use only json and text. bytes has been requested by one user without any specific API requirement. Feel free to design and add new methods or replace existing bytes.

MartinKavik avatar Apr 22 '20 11:04 MartinKavik

Thanks, I'll try a few things out and update.

platy avatar Apr 22 '20 12:04 platy

I tried a std::io::Read interface but for my use case it just caused lots of small allocations instead of one large one. I'll come back to this if I can solve that issue.

platy avatar Apr 23 '20 09:04 platy