Switchboard SDK
Loading...
Searching...
No Matches
switchboard::Result< T > Class Template Reference

Represents the result of an operation that can either succeed or fail. More...

#include <Result.hpp>

Public Member Functions

 Result (ValueType value)
 Result (Error error)
bool isSuccess () const
 Returns true if the operation was successful.
bool isError () const
 Returns true if the operation failed.
ValueType value () const
 Returns the value of the operation if it was successful.
Error error () const
 Returns the error of the operation if it failed.
Result< std::any > toAny () const
 Converts the result to a std::any type.

Detailed Description

template<typename T>
class switchboard::Result< T >

Represents the result of an operation that can either succeed or fail.

Member Function Documentation

◆ error()

template<typename T>
Error switchboard::Result< T >::error ( ) const
inlinenodiscard

Returns the error of the operation if it failed.

Returns
The error of the operation if it failed.

◆ isError()

template<typename T>
bool switchboard::Result< T >::isError ( ) const
inlinenodiscard

Returns true if the operation failed.

Returns
True if the operation failed.

◆ isSuccess()

template<typename T>
bool switchboard::Result< T >::isSuccess ( ) const
inlinenodiscard

Returns true if the operation was successful.

Returns
True if the operation was successful.

◆ toAny()

template<typename T>
Result< std::any > switchboard::Result< T >::toAny ( ) const
inlinenodiscard

Converts the result to a std::any type.

If the operation was successful, it returns a Result<std::any> containing the value. If the operation failed, it returns a Result<std::any> containing the error message.

Returns
A Result<std::any> containing either the value or the error message.

◆ value()

template<typename T>
ValueType switchboard::Result< T >::value ( ) const
inlinenodiscard

Returns the value of the operation if it was successful.

Returns
The value of the operation if it was successful.

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