(
request: Request,
on_data: Box<dyn Fn(crate::Result<Part>) -> ControlFlow<()> + Send>,
)
| 47 | } |
| 48 | |
| 49 | pub(crate) fn fetch_streaming( |
| 50 | request: Request, |
| 51 | on_data: Box<dyn Fn(crate::Result<Part>) -> ControlFlow<()> + Send>, |
| 52 | ) { |
| 53 | spawn_future(async move { |
| 54 | let mut stream = match fetch_jsvalue_stream(&request).await { |
| 55 | Ok(stream) => stream, |
| 56 | Err(e) => { |
| 57 | let _ = on_data(Err(string_from_fetch_error(e))); |
| 58 | return; |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | while let Some(chunk) = stream.next().await { |
| 63 | match chunk { |
| 64 | Ok(chunk) => { |
| 65 | if on_data(Ok(chunk)).is_break() { |
| 66 | return; |
| 67 | } |
| 68 | } |
| 69 | Err(e) => { |
| 70 | let _ = on_data(Err(string_from_fetch_error(e))); |
| 71 | return; |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | let _ = on_data(Ok(Part::Chunk(vec![]))); |
| 77 | }) |
| 78 | } |
no test coverage detected