Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::protocols::grpc::grpc_status Struct Reference

gRPC status with code, message, and optional details More...

#include <status.h>

Collaboration diagram for kcenon::network::protocols::grpc::grpc_status:
Collaboration graph

Public Member Functions

 grpc_status ()=default
 Default constructor (OK status)
 
 grpc_status (status_code c)
 Construct with status code.
 
 grpc_status (status_code c, std::string msg)
 Construct with status code and message.
 
 grpc_status (status_code c, std::string msg, std::string det)
 Construct with status code, message, and details.
 
auto is_ok () const -> bool
 Check if status is OK.
 
auto is_error () const -> bool
 Check if status represents an error.
 
auto code_string () const -> std::string_view
 Get status code as string.
 

Static Public Member Functions

static auto ok_status () -> grpc_status
 Create OK status.
 
static auto error_status (status_code c, std::string msg) -> grpc_status
 Create error status.
 

Public Attributes

status_code code = status_code::ok
 
std::string message
 
std::optional< std::string > details
 

Detailed Description

gRPC status with code, message, and optional details

Represents the status of a gRPC operation, including the status code, an optional error message, and optional encoded details (typically google.rpc.Status in binary format).

Definition at line 94 of file status.h.

Constructor & Destructor Documentation

◆ grpc_status() [1/4]

kcenon::network::protocols::grpc::grpc_status::grpc_status ( )
default

Default constructor (OK status)

◆ grpc_status() [2/4]

kcenon::network::protocols::grpc::grpc_status::grpc_status ( status_code c)
inlineexplicit

Construct with status code.

Parameters
cStatus code

Definition at line 109 of file status.h.

◆ grpc_status() [3/4]

kcenon::network::protocols::grpc::grpc_status::grpc_status ( status_code c,
std::string msg )
inline

Construct with status code and message.

Parameters
cStatus code
msgError message

Definition at line 117 of file status.h.

118 : code(c), message(std::move(msg)) {}

◆ grpc_status() [4/4]

kcenon::network::protocols::grpc::grpc_status::grpc_status ( status_code c,
std::string msg,
std::string det )
inline

Construct with status code, message, and details.

Parameters
cStatus code
msgError message
detEncoded details

Definition at line 126 of file status.h.

127 : code(c), message(std::move(msg)), details(std::move(det)) {}
std::optional< std::string > details
Definition status.h:98

Member Function Documentation

◆ code_string()

auto kcenon::network::protocols::grpc::grpc_status::code_string ( ) const -> std::string_view
inline

Get status code as string.

Returns
String representation of status code

Definition at line 145 of file status.h.

146 {
148 }
constexpr auto status_code_to_string(status_code code) -> std::string_view
Convert status code to string.
Definition status.h:61

References code, and kcenon::network::protocols::grpc::status_code_to_string().

Here is the call graph for this function:

◆ error_status()

static auto kcenon::network::protocols::grpc::grpc_status::error_status ( status_code c,
std::string msg ) -> grpc_status
inlinestatic

Create error status.

Parameters
cError code
msgError message
Returns
Error status

Definition at line 165 of file status.h.

166 {
167 return grpc_status{c, std::move(msg)};
168 }
grpc_status()=default
Default constructor (OK status)

◆ is_error()

auto kcenon::network::protocols::grpc::grpc_status::is_error ( ) const -> bool
inline

Check if status represents an error.

Returns
True if status code is not OK

Definition at line 139 of file status.h.

139{ return code != status_code::ok; }
@ ok
Not an error; returned on success.

References code, and kcenon::network::protocols::grpc::ok.

◆ is_ok()

auto kcenon::network::protocols::grpc::grpc_status::is_ok ( ) const -> bool
inline

Check if status is OK.

Returns
True if status code is OK

Definition at line 133 of file status.h.

133{ return code == status_code::ok; }

References code, and kcenon::network::protocols::grpc::ok.

◆ ok_status()

static auto kcenon::network::protocols::grpc::grpc_status::ok_status ( ) -> grpc_status
inlinestatic

Create OK status.

Returns
OK status

Definition at line 154 of file status.h.

155 {
157 }

References kcenon::network::protocols::grpc::ok.

Member Data Documentation

◆ code

◆ details

std::optional<std::string> kcenon::network::protocols::grpc::grpc_status::details

Definition at line 98 of file status.h.

◆ message


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