Brian Silverman | 7edd1ce | 2022-07-23 16:10:54 -0700 | [diff] [blame^] | 1 | #ifndef AOS_FOR_RUST_H_ |
| 2 | #define AOS_FOR_RUST_H_ |
| 3 | |
| 4 | // This file has some shared utilities for the for_rust C++ code, which provides |
| 5 | // autocxx-friendly versions of C++ APIs. |
| 6 | |
| 7 | #include <string_view> |
| 8 | |
| 9 | #include "cxx.h" |
| 10 | |
| 11 | namespace aos { |
| 12 | |
| 13 | inline rust::Str StringViewToRustStr(std::string_view s) { |
| 14 | return rust::Str(s.data(), s.size()); |
| 15 | } |
| 16 | |
| 17 | inline std::string_view RustStrToStringView(rust::Str s) { |
| 18 | return std::string_view(s.data(), s.size()); |
| 19 | } |
| 20 | |
| 21 | } // namespace aos |
| 22 | |
| 23 | #endif // AOS_FOR_RUST_H_ |