Open xrl opened 2 years ago
Streaming would need to be handled more by the user. First, you need to determine how the remote would receive it: how are the pieces streamed, is it like an array that is never closed? Or is each piece a self-contained JSON object, and they are separated by newlines?
After you've determined that, you could send a request with a channel as the body stream. Then, each time you have a part ready, you can use something like serde_json::to_vec(&item)
, and then push that on the channel.
I love the optional
json()
feature, my HTTP code looks super tidy:but I imagine I'm going to be streaming lots of data out this request. The code
json(&T)
looks like it's forcing all the data to be buffered first:specifically
serde_json::to_vec(json)
. Could this be converted to useserde_json::to_writer()
? Maybe this is a async/blocking code problem? Looks like that's the case in serde's world: https://github.com/serde-rs/json/issues/575.Just wanted to kick off a conversation here and have something searchable.