Boost.Redis: include/boost/redis/detail/write.hpp Source File

Boost.Redis 1.84.0 A redis client library

Loading...
Searching...
No Matches
write.hpp
1/* Copyright (c) 2018-2024 Marcelo Zimbres Silva (mzimbres@gmail.com)
2 *
3 * Distributed under the Boost Software License, Version 1.0. (See
4 * accompanying file LICENSE.txt)
5 */
6
7#ifndef BOOST_REDIS_WRITE_HPP
8#define BOOST_REDIS_WRITE_HPP
9
10#include <boost/asio/write.hpp>
11#include <boost/redis/request.hpp>
12
13namespace boost::redis::detail {
14
21template<class SyncWriteStream>
22 auto write(SyncWriteStream& stream, request const& req)
23{
24 return asio::write(stream, asio::buffer(req.payload()));
25}
26
27template<class SyncWriteStream>
28auto write(SyncWriteStream& stream, request const& req, system::error_code& ec)
29{
30 return asio::write(stream, asio::buffer(req.payload()), ec);
31}
32
40template<
41 class AsyncWriteStream,
42 class CompletionToken = asio::default_completion_token_t<typename AsyncWriteStream::executor_type>
43 >
44 auto async_write(
45 AsyncWriteStream& stream,
46 request const& req,
47 CompletionToken&& token =
48 asio::default_completion_token_t<typename AsyncWriteStream::executor_type>{})
49{
50 return asio::async_write(stream, asio::buffer(req.payload()), token);
51}
52
53} // boost::redis::detail
54
55#endif // BOOST_REDIS_WRITE_HPP
boost::redis::request
Creates Redis requests.
Definition request.hpp:46
boost::redis::detail::async_write
auto async_write(AsyncWriteStream &stream, request const &req, CompletionToken &&token=asio::default_completion_token_t< typename AsyncWriteStream::executor_type >{})
Writes a request asynchronously.
Definition write.hpp:44
boost::redis::detail::write
auto write(SyncWriteStream &stream, request const &req)
Writes a request synchronously.
Definition write.hpp:22