1use crate::channel;
8use crate::prelude::*;
9use crate::task::Task;
10use crate::test::Path;
11
12pub struct OutputStream {
14 pub(super) remaining: usize,
15 pub(super) rx: channel::Receiver<Output>,
16 pub(super) _task: Task<()>,
17}
18
19#[derive(Debug)]
21pub struct Output {
22 pub path: Path,
24 pub result: fail::Result,
26}
27
28impl OutputStream {
29 pub fn is_empty(&self) -> bool {
31 self.remaining == 0
32 }
33
34 pub fn len(&self) -> usize {
36 self.remaining
37 }
38
39 pub async fn next(&mut self) -> Option<Output> {
43 let result = self.rx.recv().await.ok();
44
45 if result.is_some() {
46 self.remaining -= 1;
47 } else if self.remaining > 0 {
48 panic!("OutputStream closed with {} remaining tasks.", self.remaining);
49 }
50
51 result
52 }
53}