The changes I've made to #Enigmatick over the last couple of months are significant and I plan to write more about them soon. But one of my favorite is this small bit (supported by some larger structures) in my #ActivityPub crate.
impl ApCollection {
/// Creates an async stream over all items in this collection and its linked pages.
pub fn stream_all<F, Fut>(self, fetcher: F) -> ApCollectionStream
where
F: Fn(&str) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<ApCollection, Box<dyn std::error::Error + Send + Sync>>>
+ Send
+ 'static,
{
ApCollectionStream::new(self, fetcher)
}
}
I wanted to be able to (using async code) take an ActivityPub Collection and iterate over all of its members without worrying about pulling in each page. This implementation accomplishes that.
The full source is here.