readInto method

  1. @override
Future<ReadResult> readInto(
  1. ReadBuf dst
)
override

Implementation

@override
Future<ReadResult> readInto(ReadBuf dst) async {
  if (dst.remaining == 0) return const ReadResult(0);
  if (_start == _end) {
    if (dst.remaining >= _buffer.length) {
      return inner.readInto(dst);
    }
    final ok = await fillBuf();
    if (!ok && _end == 0) return const ReadResult(0, eof: true);
  }
  final n = buffered.clamp(0, dst.remaining);
  dst.unfilled.setRange(0, n, _buffer, _start);
  dst.advance(n);
  _start += n;
  return ReadResult(n);
}