MCPcopy Create free account
hub / github.com/hashintel/hash / poll

Method poll

libs/error-stack/src/ext/stream.rs:60–92  ·  view source on GitHub ↗
(self: Pin<&mut Self>, cx: &mut Context<'_>)

Source from the content-addressed store, hash-verified

58 type Output = Result<A, Report<[C]>>;
59
60 fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
61 let mut this = self.project();
62
63 let value = loop {
64 if *this.context_len >= *this.context_bound {
65 break mem::replace(this.output, Ok(A::default()));
66 }
67
68 let next = ready!(this.stream.as_mut().try_poll_next(cx));
69 match (next, &mut *this.output) {
70 (Some(Ok(value)), Ok(output)) => {
71 output.extend(core::iter::once(value));
72 }
73 (Some(Ok(_)), Err(_)) => {
74 // we're now just consuming the iterator to return all related errors
75 // so we can just ignore the output
76 }
77 (Some(Err(error)), output @ Ok(_)) => {
78 *output = Err(error.into());
79 *this.context_len += 1;
80 }
81 (Some(Err(error)), Err(report)) => {
82 report.append(error.into());
83 *this.context_len += 1;
84 }
85 (None, output) => {
86 break mem::replace(output, Ok(A::default()));
87 }
88 }
89 };
90
91 Poll::Ready(value)
92 }
93}
94
95/// Trait extending [`TryStream`] with methods for collecting error-stack results in a fail-slow

Callers

nothing calls this directly

Calls 6

OkInterface · 0.85
ErrInterface · 0.85
appendMethod · 0.65
defaultFunction · 0.50
projectMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected