How to get a `Vec<u8>` out of a `http_body::Body`?

I'm struggling here. What I actually have is a http_body::Limited<axum::Body>, and I'm struggling to get the data out. I can see there is a poll_data method, which should give chunks of data asynchronously, but I can't see how to call this function. Sadly, I've been using async rust for a while now, but I still run into trouble whenever I encounter methods involving a Context. :frowning:

The data method seems to return a future that calls the poll_data method internally.

Any function that takes a Context needs to be called from inside an implementation of Future. You can also use poll_fn to avoid needing to create a future type.

But there should almost always be a Future type you can access rather than having to manually call poll_* functions. They're usually optimizations for niche uses.

1 Like