Adam Snaider | 48a62f3 | 2023-10-02 15:49:23 -0700 | [diff] [blame] | 1 | #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 | |
| 11 | namespace aos { |
| 12 | |
| 13 | struct 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. |
| 38 | void InitFromRust(const char *argv0); |
| 39 | |
| 40 | std::vector<FlagInfo> GetCppFlags(); |
| 41 | |
| 42 | bool SetCommandLineOption(const char *name, const char *value); |
| 43 | std::string GetCommandLineOption(const char *name); |
| 44 | |
| 45 | } // namespace aos |
| 46 | |
| 47 | #endif // AOS_INIT_FOR_RUST_H_ |