template <typename Sink>
nxt::io::byte_writer class

Buffered asynchronous writer over any sink with a write_all method.

Constructors, destructors, conversion operators

byte_writer(Sink& sink, std::span<std::byte> buffer, std::stop_token stop = {})
Use caller-owned storage as the write buffer.

Public functions

void advance(std::size_t n)
Mark n reserved bytes as written.
auto buffered() const →  std::span<const std::byte> noexcept
Bytes currently staged for writing.
auto buffered_size() const →  std::size_t noexcept
Number of staged bytes.
auto capacity() const →  std::size_t noexcept
Total buffer capacity.
auto ensure_unused_capacity(std::size_t n) →  nxt::task
Ensure at least n bytes of unused capacity.
auto flush() →  nxt::task
Flush staged bytes to the sink.
void undo(std::size_t n)
Remove n bytes from the staged output.
auto unused_capacity() →  std::span<std::byte> noexcept
Remaining writable capacity.
auto writable(std::size_t n) →  nxt::task<std::span<std::byte>>
Reserve n writable bytes, flushing first if needed.
auto write_all(std::span<const std::byte> bytes) →  nxt::task
Write all bytes, buffering small chunks and bypassing for large chunks.
auto write_all(std::string_view text) →  nxt::task
Write all text bytes.