Cppinecone
A C++ client for the Pinecone vector database
pinecone::util::result< T > Struct Template Reference

Models the possibility of failure for all Cppinecone public API operations. More...

#include <result.hpp>

Public Types

using error_type = std::variant< request_rejected, request_failed, parsing_failed >
 
using value_type = std::variant< T, error_type >
 

Public Member Functions

 result (T value) noexcept
 
 result (curl_result::error_type err) noexcept
 
 result (int64_t code, std::string body) noexcept
 
 result (json::exception const &ex) noexcept
 
 result (char const *message) noexcept
 
 result (error_type err) noexcept
 
constexpr auto failure_reason () const noexcept -> failure
 
auto to_string () const noexcept -> std::string
 Retrieves a string representation of the operation result. More...
 
constexpr auto is_successful () const noexcept -> bool
 
constexpr auto is_failed () const noexcept -> bool
 
template<typename U >
constexpr auto and_then (std::function< result< U >(T &)> const &func) noexcept -> result< U >
 Runs a transformation function on a successful result; does nothing on a failed result. More...
 
constexpr auto operator-> () noexcept -> T *
 Can be used only on successful results.
 
constexpr auto operator* () noexcept -> T &
 Can be used only on successful results.
 
constexpr auto value () noexcept -> value_type &
 

Detailed Description

template<typename T>
struct pinecone::util::result< T >

Models the possibility of failure for all Cppinecone public API operations.

Cppinecone heavily constrains the types of errors that it allows to be propagated to clients. All operations return a result, allowing the library fine-grained control over failure modes and error handling. Usage of this class can be modified with client-level policies.

Template Parameters
Tthe type held in the event of operation success

Definition at line 157 of file result.hpp.

Member Function Documentation

◆ and_then()

template<typename T >
template<typename U >
constexpr auto pinecone::util::result< T >::and_then ( std::function< result< U >(T &)> const &  func) -> result<U>
inlineconstexprnoexcept

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

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

Definition at line 252 of file result.hpp.

◆ failure_reason()

template<typename T >
constexpr auto pinecone::util::result< T >::failure_reason ( ) const -> failure
inlineconstexprnoexcept
Returns
the reason for operation failure (or a sentinel value for successful operations)

Definition at line 178 of file result.hpp.

◆ is_failed()

template<typename T >
constexpr auto pinecone::util::result< T >::is_failed ( ) const -> bool
inlineconstexprnoexcept
Returns
whether the operation failed

Definition at line 242 of file result.hpp.

◆ is_successful()

template<typename T >
constexpr auto pinecone::util::result< T >::is_successful ( ) const -> bool
inlineconstexprnoexcept
Returns
whether the operation succeeded

Definition at line 234 of file result.hpp.

◆ to_string()

template<typename T >
auto pinecone::util::result< T >::to_string ( ) const -> std::string
inlinenoexcept

Retrieves a string representation of the operation result.

The format of this string is not specified and should not be relied upon programmatically.

Returns
the string representation of the result

Definition at line 203 of file result.hpp.

◆ value()

template<typename T >
constexpr auto pinecone::util::result< T >::value ( ) -> value_type&
inlineconstexprnoexcept
Returns
the raw value contained within the result

Definition at line 274 of file result.hpp.


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