Brian Silverman | 7edd1ce | 2022-07-23 16:10:54 -0700 | [diff] [blame^] | 1 | #include "aos/configuration_for_rust.h" |
| 2 | |
| 3 | #include "aos/for_rust.h" |
| 4 | |
| 5 | namespace aos::configuration { |
| 6 | |
| 7 | const Channel *GetChannelForRust(const Configuration *config, rust::Str name, |
| 8 | rust::Str type, rust::Str application_name, |
| 9 | const Node *node) { |
| 10 | return GetChannel(config, RustStrToStringView(name), |
| 11 | RustStrToStringView(type), |
| 12 | RustStrToStringView(application_name), node); |
| 13 | } |
| 14 | |
| 15 | rust::Vec<uint8_t> MaybeReadConfigForRust( |
| 16 | rust::Str path, rust::Slice<const rust::Str> extra_import_paths) { |
| 17 | std::vector<std::string_view> cc_extra_import_paths; |
| 18 | for (const rust::Str &extra_import_path : extra_import_paths) { |
| 19 | cc_extra_import_paths.push_back(RustStrToStringView(extra_import_path)); |
| 20 | } |
| 21 | const auto cc_result = MaybeReadConfig(RustStrToStringView(path)); |
| 22 | rust::Vec<uint8_t> result; |
| 23 | if (cc_result) { |
| 24 | result.reserve(cc_result->span().size()); |
| 25 | for (uint8_t b : cc_result->span()) { |
| 26 | result.push_back(b); |
| 27 | } |
| 28 | } |
| 29 | return result; |
| 30 | } |
| 31 | |
| 32 | } // namespace aos::configuration |