nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
nros::Result Class Reference

#include <result.hpp>

Public Member Functions

ErrorCode code () const
 Get the underlying error code.
 
bool ok () const
 Returns true if the operation succeeded.
 
 operator bool () const
 Explicit bool conversion — allows if (result) { ... }.
 
int32_t raw () const
 Get the raw integer code (for FFI interop).
 
constexpr Result ()
 Default-construct a success.
 
constexpr Result (ErrorCode code)
 Construct from a typed code.
 
constexpr Result (int32_t raw)
 Construct from a raw FFI return value (int32_t).
 

Static Public Member Functions

static constexpr Result success ()
 Named constructors.
 

Detailed Description

Result type for fallible operations.

This replaces exceptions in freestanding C++. Use the NROS_TRY macro for early return on error.

Constructor & Destructor Documentation

◆ Result() [1/3]

constexpr nros::Result::Result ( )
inlineconstexpr

Default-construct a success.

◆ Result() [2/3]

constexpr nros::Result::Result ( ErrorCode  code)
inlineconstexpr

Construct from a typed code.

◆ Result() [3/3]

constexpr nros::Result::Result ( int32_t  raw)
inlineconstexpr

Construct from a raw FFI return value (int32_t).

Member Function Documentation

◆ code()

ErrorCode nros::Result::code ( ) const
inline

Get the underlying error code.

◆ ok()

bool nros::Result::ok ( ) const
inline

Returns true if the operation succeeded.

◆ operator bool()

nros::Result::operator bool ( ) const
inlineexplicit

Explicit bool conversion — allows if (result) { ... }.

◆ raw()

int32_t nros::Result::raw ( ) const
inline

Get the raw integer code (for FFI interop).

◆ success()

static constexpr Result nros::Result::success ( )
inlinestaticconstexpr

Named constructors.


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