Cppinecone
A C++ client for the Pinecone vector database
pinecone::util::curl_result Struct Reference

Models the possibly of failure for remote HTTP operations. More...

#include <curl_result.hpp>

Public Types

using error_type = std::variant< CURLcode, curl_slist * >
 

Public Member Functions

constexpr curl_result (CURLcode code) noexcept
 Constructs a result from a CURL error code. More...
 
constexpr curl_result (curl_slist *list) noexcept
 Constructs a result from a CURL header list. More...
 
constexpr auto is_success () const noexcept -> bool
 
constexpr auto is_error () const noexcept -> bool
 
constexpr auto error () const noexcept -> error_type
 Retrieves the error type associated with a failed operation. Cannot be called on a successful result. More...
 
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. More...
 
auto to_string () const noexcept -> std::string
 Retrieves the string representation of the current instance. More...
 

Static Public Member Functions

static auto to_string (error_type const &err) noexcept -> std::string
 Retrieves the string representation of a failed operation. More...
 

Detailed Description

Models the possibly of failure for remote HTTP operations.

Definition at line 20 of file curl_result.hpp.

Constructor & Destructor Documentation

◆ curl_result() [1/2]

constexpr pinecone::util::curl_result::curl_result ( CURLcode  code)
inlineconstexprnoexcept

Constructs a result from a CURL error code.

This constructor is intentionally non-explicit to facilitate converting construction.

Definition at line 30 of file curl_result.hpp.

◆ curl_result() [2/2]

constexpr pinecone::util::curl_result::curl_result ( curl_slist *  list)
inlineconstexprnoexcept

Constructs a result from a CURL header list.

This constructor is intentionally non-explicit to facilitate converting construction.

Definition at line 44 of file curl_result.hpp.

Member Function Documentation

◆ and_then()

constexpr auto pinecone::util::curl_result::and_then ( std::function< curl_result()> const &  func) const -> curl_result
inlineconstexprnoexcept

Runs a transformation function on a successful result; does nothing on a failed result.

Parameters
functhe transformation function to apply on a successful result
Returns
the result of the transformation (or the propagated error)

Definition at line 80 of file curl_result.hpp.

◆ error()

constexpr auto pinecone::util::curl_result::error ( ) const -> error_type
inlineconstexprnoexcept

Retrieves the error type associated with a failed operation. Cannot be called on a successful result.

Returns
the associated error

Definition at line 69 of file curl_result.hpp.

◆ is_error()

constexpr auto pinecone::util::curl_result::is_error ( ) const -> bool
inlineconstexprnoexcept
Returns
whether the current instance represents a failed operation

Definition at line 61 of file curl_result.hpp.

◆ is_success()

constexpr auto pinecone::util::curl_result::is_success ( ) const -> bool
inlineconstexprnoexcept
Returns
whether the current instance represents a successful operation

Definition at line 56 of file curl_result.hpp.

◆ to_string() [1/2]

auto pinecone::util::curl_result::to_string ( ) const -> std::string
inlinenoexcept

Retrieves the string representation of the current instance.

The format of the string returned by this function is not specified and should not be relied upon programmatically.

Returns
the string representation of the operation result

Definition at line 110 of file curl_result.hpp.

Referenced by pinecone::util::result< T >::to_string().

◆ to_string() [2/2]

static auto pinecone::util::curl_result::to_string ( error_type const &  err) -> std::string
inlinestaticnoexcept

Retrieves the string representation of a failed operation.

Parameters
errthe error to stringify
Returns
the string representation of the error

Definition at line 95 of file curl_result.hpp.


The documentation for this struct was generated from the following file: