dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
dfx::Client::Message Class Reference

Wrapper around a JSON message returned by the client protocol/API. More...

#include <dfx-client/Message.hpp>

Public Types

enum class  Type { Success , Error }
 High-level message category. More...

Public Member Functions

 Message (nlohmann::json json)
 Construct a message wrapper from a JSON payload.
bool isOk () const noexcept
 True if this message represents a successful response.
bool isError () const noexcept
 True if this message represents an error response.
Type type () const noexcept
 Return the message type determined at construction.
nlohmann::json const & json () const noexcept
 Access the underlying JSON payload (read-only).
nlohmann::json result () const noexcept
 Extract the "result" portion (if any) of the message.
std::vector< std::string > errors () const
 Extract the error list from the message.

Detailed Description

Wrapper around a JSON message returned by the client protocol/API.

Message encapsulates a raw nlohmann::json payload and classifies it into a high-level Type (success or error).

The class provides helpers to:

  • query whether the message represents success or failure,
  • access the underlying JSON payload,
  • extract a "result" object for successful responses,
  • extract error strings for failed responses.

The exact JSON schema is defined by the protocol used by the project; this class only exposes the parts it needs via result() and errors().

Member Enumeration Documentation

◆ Type

enum class dfx::Client::Message::Type
strong

High-level message category.

Enumerator
Success 

Message represents a successful response.

Error 

Message represents a failure response.

Constructor & Destructor Documentation

◆ Message()

dfx::Client::Message::Message ( nlohmann::json json)
explicit

Construct a message wrapper from a JSON payload.

Parameters
jsonRaw JSON payload.

The constructor determines the message Type from the content of json

Member Function Documentation

◆ errors()

std::vector< std::string > dfx::Client::Message::errors ( ) const

Extract the error list from the message.

◆ isError()

bool dfx::Client::Message::isError ( ) const
inlinenoexcept

True if this message represents an error response.

◆ isOk()

bool dfx::Client::Message::isOk ( ) const
inlinenoexcept

True if this message represents a successful response.

◆ json()

nlohmann::json const & dfx::Client::Message::json ( ) const
inlinenoexcept

Access the underlying JSON payload (read-only).

◆ result()

nlohmann::json dfx::Client::Message::result ( ) const
noexcept

Extract the "result" portion (if any) of the message.

◆ type()

Type dfx::Client::Message::type ( ) const
inlinenoexcept

Return the message type determined at construction.


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