boost::capy::push_to
Transfer data from a BufferSource to a WriteStream.
Synopsis
Declared in <boost/capy/io/push_to.hpp>
template<
BufferSource Src,
WriteStream Stream>
requires (!WriteSink<Stream>)
io_task<std::size_t>
push_to(
Src& source,
Stream& stream);
Description
This function pulls data from the source and writes it to the stream until the source is exhausted or an error occurs. The stream uses write_some() which may perform partial writes, so this function loops until all pulled data is consumed.
Unlike the WriteSink overload, this function does not signal EOF explicitly since WriteStream does not provide a write_eof method. The transfer completes when the source is exhausted.
Example
task<void> transfer_body(BufferSource auto& source, WriteStream auto& stream)
{
auto [ec, n] = co_await push_to(source, stream);
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 |
Stream |
The stream type, must satisfy |
Parameters
| Name | Description |
|---|---|
source |
The source to pull data from. |
stream |
The stream to write data to. |
See Also
BufferSource, WriteStream, pull_from
Created with MrDocs