|
LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
|
Lightweight success-or-error return type for non-exceptional API failures. More...
#include <result.h>
Public Member Functions | |
| bool | ok () const noexcept |
| True when the result contains a success value. | |
| bool | hasError () const noexcept |
| True when the result contains an error. | |
| operator bool () const noexcept | |
Allows if (result) style success checks. | |
| T & | value () & |
| Access the success value. | |
| const T & | value () const & |
| Access the success value. | |
| T && | value () && |
| Move the success value out. | |
| const T && | value () const && |
| Move the success value out. | |
| E & | error () & |
| Access the error value. | |
| const E & | error () const & |
| Access the error value. | |
| E && | error () && |
| Move the error value out. | |
| const E && | error () const && |
| Move the error value out. | |
Static Public Member Functions | |
| template<typename U = T, typename = std::enable_if_t<std::is_constructible<T, U&&>::value>> | |
| static Result | success (U &&value) |
| Construct a successful result containing a value. | |
| template<typename F = E, typename = std::enable_if_t<std::is_constructible<E, F&&>::value>> | |
| static Result | failure (F &&error) |
| Construct a failed result containing an error. | |
Lightweight success-or-error return type for non-exceptional API failures.
This is intended for SDK operations where callers are expected to branch on success vs. failure, such as back-pressure or an unpublished track.
Result<T, E> stores either:
T, orEAccessors validate their preconditions before returning. Calling value() on an error result, or error() on a success result, throws std::logic_error. Avoid this by checking ok() / hasError() / if (result) before calling value() or error().
|
inline |
Access the error value.
| std::logic_error | if hasError() == false. |
|
inline |
Move the error value out.
| std::logic_error | if hasError() == false. |
|
inline |
Access the error value.
| std::logic_error | if hasError() == false. |
|
inline |
Move the error value out.
| std::logic_error | if hasError() == false. |
|
inline |
Access the success value.
| std::logic_error | if ok() == false. |
|
inline |
Move the success value out.
| std::logic_error | if ok() == false. |
|
inline |
Access the success value.
| std::logic_error | if ok() == false. |
|
inline |
Move the success value out.
| std::logic_error | if ok() == false. |