boost::capy::push_to
Transfer data from a BufferSource to a WriteSink.
Synopsis
Declared in <boost/capy/io/push_to.hpp>
template<
BufferSource Src,
WriteSink Sink>
io_task<std::size_t>
push_to(
Src& source,
Sink& sink);
Description
This function pulls data from the source and writes it to the sink until the source is exhausted or an error occurs. When the source signals completion, write_eof() is called on the sink to finalize the transfer.
Example
task<void> transfer_body(BufferSource auto& source, WriteSink auto& sink)
{
auto [ec, n] = co_await push_to(source, sink);
if (ec)
{
// Handle error
}
// n bytes were transferred
}
Return Value
A task that yields (std::error_code, std::size_t). On success, ec is default‐constructed (no error) and n is the total number of bytes transferred. On error, ec contains the error code and n is the total number of bytes transferred before the error.
Template Parameters
| Name | Description |
|---|---|
Src |
The source type, must satisfy |
Sink |
The sink type, must satisfy |
Parameters
| Name | Description |
|---|---|
source |
The source to pull data from. |
sink |
The sink to write data to. |
See Also
BufferSource, WriteSink
Created with MrDocs