boost::capy::pull_from
Transfer data from a ReadSource to a BufferSink.
Synopsis
Declared in <boost/capy/io/pull_from.hpp>
template<
ReadSource Src,
BufferSink Sink>
io_task<std::size_t>
pull_from(
Src& source,
Sink& sink);
Description
This function reads data from the source directly into the sink's internal buffers using the callee‐owns‐buffers model. The sink provides writable buffers via prepare(), the source reads into them, and the sink commits the data. When the source signals EOF, commit_eof() is called on the sink to finalize the transfer.
Example
task<void> transfer_body(ReadSource auto& source, BufferSink auto& sink)
{
auto [ec, n] = co_await pull_from(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 read data from. |
sink |
The sink to write data to. |
See Also
ReadSource, BufferSink, push_to
Created with MrDocs