ignore.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* Copyright (c) 2018-2023 Marcelo Zimbres Silva ([email protected])
  2. *
  3. * Distributed under the Boost Software License, Version 1.0. (See
  4. * accompanying file LICENSE.txt)
  5. */
  6. #ifndef BOOST_REDIS_ADAPTER_IGNORE_HPP
  7. #define BOOST_REDIS_ADAPTER_IGNORE_HPP
  8. #include <boost/redis/resp3/node.hpp>
  9. #include <boost/redis/error.hpp>
  10. #include <boost/system/error_code.hpp>
  11. #include <string>
  12. namespace boost::redis::adapter
  13. {
  14. /** @brief An adapter that ignores responses
  15. * @ingroup high-level-api
  16. *
  17. * RESP3 errors won't be ignored.
  18. */
  19. struct ignore {
  20. void operator()(resp3::basic_node<std::string_view> const& nd, system::error_code& ec)
  21. {
  22. switch (nd.data_type) {
  23. case resp3::type::simple_error: ec = redis::error::resp3_simple_error; break;
  24. case resp3::type::blob_error: ec = redis::error::resp3_blob_error; break;
  25. case resp3::type::null: ec = redis::error::resp3_null; break;
  26. default:;
  27. }
  28. }
  29. };
  30. } // boost::redis::adapter
  31. #endif // BOOST_REDIS_ADAPTER_IGNORE_HPP