Ok I'd like to start a small discussion (it sparkled from something I needed to do at my job), I want to see if it leads to anything interesting.
Suppose you have some company that provides a public API that lets you fetch a bunch of objects in pages (let's say you do a GET HTTP request and it gives you like the next 100 objects in a JSON list), and you need to write a script that has different routines inside of it that might process these objects differently, and you can choose one of them at startup. To clarify, all of them need to process the entirety of the objects that the API provides, so the routine needs to read all pages and process them continuously. It could process it in various ways: you could imagine that the objects have relations to each other and that the routine is constructing some graph, or that the routine is filtering some important information needed for something you'll do later, or whatever else. A routine might keep track of some state while it's processing these objects to do this - for example you could have a very simple routine that just counts the number of objects that it has fetched.
How would you abstract this so that you can implement different routines operating on the same requests?
(in Rust btw - may as well stay on one language xd)