11 #include <curl/curl.h> 
   15 namespace pinecone::util
 
   21   using error_type = std::variant<CURLcode, curl_slist*>;
 
   32     if (code != CURLE_OK) {
 
   46     if (list == 
nullptr) {
 
   56   [[nodiscard]] constexpr 
auto is_success() const noexcept -> 
bool { 
return _value.index() == 0; }
 
   61   [[nodiscard]] constexpr 
auto is_error() const noexcept -> 
bool { 
return !is_success(); }
 
   69   [[nodiscard]] constexpr 
auto error() const noexcept -> error_type
 
   71     return std::get<error_type>(_value);
 
   99                          [](curl_slist*) -> 
std::string { 
return "Bad header list"; }},
 
  112     switch (_value.index()) {
 
  116         return to_string(error());
 
  123   std::variant<std::monostate, error_type> _value;
 
Models the possibly of failure for remote HTTP operations.
 
constexpr auto and_then(std::function< curl_result()> const &func) const noexcept -> curl_result
Runs a transformation function on a successful result; does nothing on a failed result.
 
constexpr auto error() const noexcept -> error_type
Retrieves the error type associated with a failed operation. Cannot be called on a successful result.
 
constexpr curl_result(CURLcode code) noexcept
Constructs a result from a CURL error code.
 
constexpr auto is_error() const noexcept -> bool
 
constexpr auto is_success() const noexcept -> bool
 
auto to_string() const noexcept -> std::string
Retrieves the string representation of the current instance.
 
constexpr curl_result(curl_slist *list) noexcept
Constructs a result from a CURL header list.
 
static auto to_string(error_type const &err) noexcept -> std::string
Retrieves the string representation of a failed operation.
 
Basic visitor operations.
 
Simple visitor implementation.