Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Justin Thomas
Justin Thomas
@jdt@enigmatick.social  ·  activity timestamp 6 months ago

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.

  • Copy link
  • Flag this post
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1-beta.35 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct