FastLED 3.10.8
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 FL_NO_EXCEPT
Get the success value (const)
#define FL_WARN(...)
Definition log.h:437
PromiseResult< T > await_top_level(Promise< T > p) FL_NO_EXCEPT
Synchronously wait for a promise to complete (ONLY safe in top-level contexts)
Definition executor.h:193
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

Definition at line 41 of file promise_result.h.

#include <promise_result.h>

Public Member Functions

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

Private Attributes

fl::variant< T, Error > mResult
 

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