ignore.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Copyright (c) 2018-2025 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. #ifndef BOOST_REDIS_ADAPTER_IGNORE_HPP
  7. #define BOOST_REDIS_ADAPTER_IGNORE_HPP
  8. #include <boost/redis/error.hpp>
  9. #include <boost/redis/resp3/node.hpp>
  10. #include <boost/system/error_code.hpp>
  11. namespace boost::redis::adapter {
  12. /** @brief An adapter that ignores responses.
  13. *
  14. * RESP3 errors won't be ignored.
  15. */
  16. struct ignore {
  17. void on_init() { }
  18. void on_done() { }
  19. void on_node(resp3::basic_node<std::string_view> const& nd, system::error_code& ec)
  20. {
  21. switch (nd.data_type) {
  22. case resp3::type::simple_error: ec = redis::error::resp3_simple_error; break;
  23. case resp3::type::blob_error: ec = redis::error::resp3_blob_error; break;
  24. case resp3::type::null: ec = redis::error::resp3_null; break;
  25. default: ;
  26. }
  27. }
  28. };
  29. } // namespace boost::redis::adapter
  30. #endif // BOOST_REDIS_ADAPTER_IGNORE_HPP