blob: 86bfd665467028828169d37a2f473e3d1e9a0ab1 [file] [log] [blame]
Adam Snaider48a62f32023-10-02 15:49:23 -07001#ifndef AOS_INIT_FOR_RUST_H_
2#define AOS_INIT_FOR_RUST_H_
3
4#include <string>
5#include <string_view>
6#include <vector>
7
8#include "aos/for_rust.h"
9#include "cxx.h"
10
11namespace aos {
12
13struct FlagInfo {
14 std::string name_;
15 std::string type_;
16 std::string description_;
17 std::string default_value_;
18 std::string filename_;
19
20 rust::Str name() const {
21 return StringViewToRustStr(std::string_view(name_));
22 }
23 rust::Str ty() const { return StringViewToRustStr(std::string_view(type_)); }
24 rust::Str description() const {
25 return StringViewToRustStr(std::string_view(description_));
26 }
27 rust::Str default_value() const {
28 return StringViewToRustStr(std::string_view(default_value_));
29 }
30 rust::Str filename() const {
31 return StringViewToRustStr(std::string_view(filename_));
32 }
33};
34
35// A special initialization function that initializes the C++ parts in a way
36// compatible with Rust. This requires careful coordination with `:init_rs`, do
37// not use it from anywhere else.
38void InitFromRust(const char *argv0);
39
40std::vector<FlagInfo> GetCppFlags();
41
42bool SetCommandLineOption(const char *name, const char *value);
43std::string GetCommandLineOption(const char *name);
44
45} // namespace aos
46
47#endif // AOS_INIT_FOR_RUST_H_