LightlyEdge C++ SDK
Loading...
Searching...
No Matches
lightly_edge_rs_bindings_ext.h
1/* © 2024 Lightly AI. All rights reserved. */
2
3#ifndef LIGHTLY_EDGE_RS_BINDINGS_EXT_H
4#define LIGHTLY_EDGE_RS_BINDINGS_EXT_H
5
6#include "lightly_edge_error.h"
7#include "lightly_edge_rs_bindings.h"
8#include "tl/expected.hpp"
9
10namespace lightly_edge_rs {
11
12// Creates a CStatus instance. It should be used for testing only.
13inline auto create_status(uint16_t code, const char *error_message) -> CStatus {
14 return create_status_impl(code, error_message);
15}
16
17// Converts CStatus to tl::unexpected. The CStatus object is deallocated and can not
18// be used anymore.
19inline auto status_to_unexpected(CStatus *status)
20 -> tl::unexpected<lightly_edge_sdk::Error> {
21 std::string message;
22 if (status->error_message != nullptr) {
23 message = status->error_message;
24 free_status_message(status);
25 }
26 return tl::make_unexpected(lightly_edge_sdk::Error(status->code, message));
27}
28
29} // namespace lightly_edge_rs
30
31#endif // LIGHTLY_EDGE_RS_BINDINGS_EXT_H
Error struct to hold error code and message.
Definition lightly_edge_error.h:20