internal AsyncEnumerable(AsyncReader <T> reader) { Reader = reader; }
internal AsyncEnumerator(AsyncReader <T> reader, CancellationToken token) { Current = default; Reader = reader; Token = token; }
// wait for a tryreadasync to finish, then continue async static async ValueTask <List <T> > ReadAllAsync_ContinueAfterTryReadAsync(AsyncReader <T> self, ValueTask <ReadResult <T> > waitFor, List <T> ret, CancellationToken cancel) { var other = await waitFor; if (other.HasValue) { ret.Add(other.Value); } else { return(ret); } while (true) { var res = await self.TryReadAsync(cancel); if (res.HasValue) { ret.Add(res.Value); } else { break; } } return(ret); }