FastLED 3.9.15
Loading...
Searching...
No Matches
fl::task::PromiseResult< T > Class Template Reference

Detailed Description

template<typename T>
class fl::task::PromiseResult< T >

Result type for promise operations.

Template Parameters
TThe success value type

PromiseResult provides a clean API for handling success/error results from async operations. It wraps a variant<T, Error> but provides more ergonomic access patterns with ok() checking and automatic assertions.

Examples

if (result.ok()) {
int value = result.value(); // Safe access
FL_WARN("Success: " << value);
} else {
FL_WARN("Error: " << result.error().message);
}
// Or use operator bool
if (result) {
FL_WARN("Got: " << result.value());
}
const T & value() const
Get the success value (const)
#define FL_WARN(X)
Definition log.h:276
PromiseResult< T > await_top_level(Promise< T > p)
Synchronously wait for a promise to complete (ONLY safe in top-level contexts)
Definition executor.h:186
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

Definition at line 40 of file promise_result.h.

#include <promise_result.h>

Public Member Functions

 PromiseResult (const Error &error)
 Construct an error PromiseResult.
 
 PromiseResult (const T &value)
 Construct a successful PromiseResult.
 
 PromiseResult (Error &&error)
 Construct an error PromiseResult (move)
 
 PromiseResult (T &&value)
 Construct a successful PromiseResult (move)
 
const Errorerror () const
 Get the error value.
 
fl::string error_message () const
 Get the error message as a convenience.
 
bool ok () const
 Check if the result is successful.
 
 operator bool () const
 Boolean conversion operator (same as ok())
 
T & value ()
 Get the success value (mutable)
 
const T & value () const
 Get the success value (const)
 
const fl::variant< T, Error > & variant () const
 Access the underlying variant (for advanced usage)
 

Private Attributes

fl::variant< T, ErrormResult
 

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