Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/modules/ROOT/pages/2.guide/2n.extending.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct MyRequestBody
{
std::optional<std::string> content_type() const;
std::optional<std::uint64_t> content_length() const;
capy::io_task<> write(http::any_buffer_sink& sink) const;
capy::task<capy::results<>> write(http::any_buffer_sink& sink) const;
};
----

Expand Down Expand Up @@ -62,7 +62,7 @@ auto [ec, r] = co_await client.post("https://example.com/post")
To read a response into a value with cpp:request_builder::as<T>[as<T>] or
cpp:request_builder::try_as<T>[try_as<T>], provide a `tag_invoke` overload
taking cpp:body_to_tag<T>[] and the cpp:response[]. It returns a
`capy::io_task<T>` that reads the body and converts it:
`capy::task<capy::results<T>>` that reads the body and converts it:

[source,cpp]
----
Expand Down Expand Up @@ -94,7 +94,7 @@ declares the extra parameter after the cpp:response[]:

[source,cpp]
----
capy::io_task<std::filesystem::path>
capy::task<capy::results<std::filesystem::path>>
tag_invoke(
burl::body_to_tag<std::filesystem::path>,
burl::response& resp,
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ for the client to speak HTTP over:
----
burl::client::config cfg;
cfg.connect_handler =
[](urls::url_view) -> capy::io_task<capy::any_stream>
[](urls::url_view) -> capy::task<capy::results<capy::any_stream>>
{
auto [a, b] = capy::test::make_stream_pair();
// drive b from the test as the "server"; hand a to the client
Expand Down
4 changes: 2 additions & 2 deletions example/nlohmann_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tag_invoke(burl::body_from_tag<nlohmann::json>, const nlohmann::json& value)
return text_.size();
}

capy::io_task<>
capy::task<capy::results<>>
write(http::any_buffer_sink& sink) const
{
auto [ec, n] = co_await sink.write_eof(capy::make_buffer(text_));
Expand All @@ -61,7 +61,7 @@ tag_invoke(burl::body_from_tag<nlohmann::json>, const nlohmann::json& value)
// end::body_from[]

// tag::body_to[]
capy::io_task<nlohmann::json>
capy::task<capy::results<nlohmann::json>>
tag_invoke(burl::body_to_tag<nlohmann::json>, burl::response& resp)
{
// Try the parser's in-place buffer first; it is allocation-free
Expand Down
9 changes: 5 additions & 4 deletions include/boost/burl/any_request_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include <boost/burl/detail/config.hpp>
#include <boost/burl/request_body.hpp>

#include <boost/capy/io_task.hpp>
#include <boost/capy/results.hpp>
#include <boost/capy/task.hpp>
#include <boost/http/io/any_buffer_sink.hpp>

#include <cstdint>
Expand Down Expand Up @@ -58,7 +59,7 @@ class any_request_body
virtual std::optional<std::uint64_t>
content_length() const = 0;

virtual capy::io_task<>
virtual capy::task<capy::results<>>
write(http::any_buffer_sink& sink) const = 0;
};

Expand All @@ -84,7 +85,7 @@ class any_request_body
return body.content_length();
}

capy::io_task<>
capy::task<capy::results<>>
write(http::any_buffer_sink& sink) const override
{
return body.write(sink);
Expand Down Expand Up @@ -214,7 +215,7 @@ class any_request_body

@return An awaitable yielding `(error_code)`.
*/
capy::io_task<>
capy::task<capy::results<>>
write(http::any_buffer_sink& sink) const
{
return impl_->write(sink);
Expand Down
12 changes: 7 additions & 5 deletions include/boost/burl/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

#include <boost/capy/ex/executor_ref.hpp>
#include <boost/capy/io/any_stream.hpp>
#include <boost/capy/io_task.hpp>
#include <boost/capy/results.hpp>
#include <boost/capy/task.hpp>
#include <boost/corosio/endpoint.hpp>
#include <boost/corosio/tls_context.hpp>
#include <boost/url/url.hpp>
Expand Down Expand Up @@ -298,7 +299,8 @@ class client
@par Example
@code
cfg.connect_handler =
[](urls::url_view) -> capy::io_task<capy::any_stream>
[](urls::url_view)
-> capy::task<capy::results<capy::any_stream>>
{
auto [a, b] = capy::test::make_stream_pair();
// drive b from the test; hand a to the client
Expand All @@ -307,7 +309,7 @@ class client
@endcode
*/
std::function<
capy::io_task<capy::any_stream>(urls::url_view url)>
capy::task<capy::results<capy::any_stream>>(urls::url_view url)>
connect_handler;
};

Expand Down Expand Up @@ -581,12 +583,12 @@ class client
@see @ref request_builder::send.
*/
BOOST_BURL_DECL
capy::io_task<response>
capy::task<capy::results<response>>
execute(burl::request request);

private:
BOOST_BURL_DECL
capy::io_task<response>
capy::task<capy::results<response>>
execute_impl(
burl::request request,
std::optional<config::clock::time_point> deadline);
Expand Down
4 changes: 2 additions & 2 deletions include/boost/burl/conversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct body_from_tag
object of type `T`. They have the form:

@code
capy::io_task<T>
capy::task<capy::results<T>>
tag_invoke(body_to_tag<T>, response& resp, Args... args);
@endcode

Expand All @@ -70,7 +70,7 @@ struct body_from_tag
@par Example
Adding support for a user-defined type:
@code
capy::io_task<my_type>
capy::task<capy::results<my_type>>
tag_invoke(burl::body_to_tag<my_type>, burl::response& resp)
{
auto [ec, sv] = co_await resp.try_as_view();
Expand Down
21 changes: 11 additions & 10 deletions include/boost/burl/detail/connection_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include <boost/burl/test/fwd.hpp>
#include <boost/capy/buffers.hpp>
#include <boost/capy/detail/buffer_array.hpp>
#include <boost/capy/io_task.hpp>
#include <boost/capy/results.hpp>
#include <boost/capy/task.hpp>

#include <chrono>
#include <cstddef>
Expand All @@ -40,14 +41,14 @@ class connection

public:
template<capy::MutableBufferSequence MB>
capy::io_task<std::size_t>
capy::task<capy::results<std::size_t>>
read_some(MB buffers)
{
return read_some_impl(buffers);
}

template<capy::ConstBufferSequence CB>
capy::io_task<std::size_t>
capy::task<capy::results<std::size_t>>
write_some(CB buffers)
{
return write_some_impl(buffers);
Expand All @@ -62,22 +63,22 @@ class connection
virtual bool
is_open() const noexcept = 0;

// virtual capy::io_task<>
// virtual capy::task<capy::results<>>
// shutdown() = 0;

virtual ~connection() = default;

private:
capy::io_task<std::size_t>
capy::task<capy::results<std::size_t>>
read_some_impl(capy::detail::mutable_buffer_array<8>);

capy::io_task<std::size_t>
capy::task<capy::results<std::size_t>>
write_some_impl(capy::detail::const_buffer_array<8>);

virtual capy::io_task<std::size_t>
virtual capy::task<capy::results<std::size_t>>
do_read_some(std::span<capy::mutable_buffer const> buffers) = 0;

virtual capy::io_task<std::size_t>
virtual capy::task<capy::results<std::size_t>>
do_write_some(std::span<capy::const_buffer const> buffers) = 0;
};

Expand All @@ -94,14 +95,14 @@ class pooled_connection
pooled_connection() = default;

template<capy::MutableBufferSequence MB>
capy::io_task<std::size_t>
capy::task<capy::results<std::size_t>>
read_some(MB buffers)
{
return conn_->read_some(std::move(buffers));
}

template<capy::ConstBufferSequence CB>
capy::io_task<std::size_t>
capy::task<capy::results<std::size_t>>
write_some(CB buffers)
{
return conn_->write_some(std::move(buffers));
Expand Down
5 changes: 3 additions & 2 deletions include/boost/burl/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <boost/burl/detail/config.hpp>
#include <boost/burl/response.hpp>

#include <boost/capy/io_task.hpp>
#include <boost/capy/results.hpp>
#include <boost/capy/task.hpp>
#include <boost/corosio/file_base.hpp>

#include <filesystem>
Expand Down Expand Up @@ -78,7 +79,7 @@ tag_invoke(body_from_tag<std::filesystem::path>, std::filesystem::path path);
`(error_code,std::filesystem::path)`.
*/
BOOST_BURL_DECL
capy::io_task<std::filesystem::path>
capy::task<capy::results<std::filesystem::path>>
tag_invoke(
body_to_tag<std::filesystem::path>,
response& resp,
Expand Down
11 changes: 6 additions & 5 deletions include/boost/burl/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <boost/burl/detail/config.hpp>
#include <boost/burl/response.hpp>

#include <boost/capy/io_task.hpp>
#include <boost/capy/results.hpp>
#include <boost/capy/task.hpp>
#include <boost/json/value.hpp>

namespace boost
Expand Down Expand Up @@ -64,7 +65,7 @@ tag_invoke(body_from_tag<json::value>, json::value value);
`(error_code,json::value)`.
*/
BOOST_BURL_DECL
capy::io_task<json::value>
capy::task<capy::results<json::value>>
tag_invoke(body_to_tag<json::value>, response& resp);

/** Create a request body from a JSON object.
Expand Down Expand Up @@ -110,7 +111,7 @@ tag_invoke(body_from_tag<json::object>, json::object value);
`(error_code,json::object)`.
*/
BOOST_BURL_DECL
capy::io_task<json::object>
capy::task<capy::results<json::object>>
tag_invoke(body_to_tag<json::object>, response& resp);

/** Create a request body from a JSON array.
Expand Down Expand Up @@ -156,7 +157,7 @@ tag_invoke(body_from_tag<json::array>, json::array value);
`(error_code,json::array)`.
*/
BOOST_BURL_DECL
capy::io_task<json::array>
capy::task<capy::results<json::array>>
tag_invoke(body_to_tag<json::array>, response& resp);

/** Create a request body from a JSON string.
Expand Down Expand Up @@ -202,7 +203,7 @@ tag_invoke(body_from_tag<json::string>, json::string value);
`(error_code,json::string)`.
*/
BOOST_BURL_DECL
capy::io_task<json::string>
capy::task<capy::results<json::string>>
tag_invoke(body_to_tag<json::string>, response& resp);

} // namespace burl
Expand Down
Loading
Loading