mlemesle / rustemon

A wrapper library for PokeApi, written in Rust
MIT License
27 stars 10 forks source link

Add "get_all_pages" function to all endpoints #15

Closed ChaseParate closed 1 year ago

ChaseParate commented 1 year ago

This is a more convenient way to get all of the resources from a given endpoint.

mlemesle commented 1 year ago

Hey there !

Thanks for contributing ! This is indeed a nice addition to the library, thanks !

However, the algorithm is quite heavy. I think it will be easier if we call the first page and then the next pages while some are present. What do you think ?

mlemesle commented 1 year ago

Hey @ChaseParate !

Do you plan to do the changes or should I take care of it ? I'd like to make a release soon :slightly_smiling_face:

Please let me know, thanks

ChaseParate commented 1 year ago

Sorry, I've been super busy! I've just implemented the changes you mentioned and it seems much more concise! I was wondering if the function should be named "get_all" or "get_all_resources" instead of "get_all_pages". What do you think?

ChaseParate commented 1 year ago

Also, perhaps there is a way to return the paginated data without needing to await every page? Something like a Stream comes to mind, but I'm not too familiar with the futures crate.

mlemesle commented 1 year ago

Hey there, no worries !

Thanks for the update, this is much more readable.

Regarding futures to avoid awaiting every pages, do you wanna do it ? Please let me know :slightly_smiling_face:

ChaseParate commented 1 year ago

I did a few prototypes with Streams, but I just couldn't quite get it to work. Maybe it would be worthwhile to investigate later.

mlemesle commented 1 year ago

Thanks for your contribution !