| 593 | std::string error() const { return buf_ ? f_.error() : std::string("out of memory for the read buffer"); } |
| 594 | SessionError kind() const { return buf_ ? f_.kind() : SessionError::memory; } |
| 595 | bool read(void* p, size_t n) { |
| 596 | uint8_t* d = static_cast<uint8_t*>(p); |
| 597 | while (n) { |
| 598 | if (at_ == have_ && !fill()) return false; |
| 599 | const size_t c = std::min(n, have_ - at_); |
| 600 | std::memcpy(d, buf_.get() + at_, c); |
| 601 | at_ += c; d += c; n -= c; |
| 602 | } |
| 603 | return true; |
| 604 | } |
| 605 | std::optional<Ticker> progress; |
| 606 | uint64_t expected = 0; |
| 607 | private: |