Expose some Channel strings to Rust from C++ wrappers
I can't find a better way to do this, so it looks like we have to
manually wrap each of these with two C++ wrapper functions for now.
Change-Id: I3df44d99a7eae96e7eb41eb70e90737087c79c23
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
diff --git a/aos/configuration_for_rust.h b/aos/configuration_for_rust.h
index 9bf9c75..c01ef57 100644
--- a/aos/configuration_for_rust.h
+++ b/aos/configuration_for_rust.h
@@ -1,7 +1,10 @@
#ifndef AOS_CONFIGURATION_FOR_RUST_H_
#define AOS_CONFIGURATION_FOR_RUST_H_
+#include <optional>
+
#include "aos/configuration.h"
+#include "aos/for_rust.h"
#include "cxx.h"
namespace aos::configuration {
@@ -18,6 +21,20 @@
rust::Vec<uint8_t> MaybeReadConfigForRust(
rust::Str path, rust::Slice<const rust::Str> extra_import_paths);
+inline bool HasChannelTypeForRust(const Channel &channel) {
+ return channel.type();
+}
+inline rust::Str GetChannelTypeForRust(const Channel &channel) {
+ return StringViewToRustStr(channel.type()->string_view());
+}
+
+inline bool HasChannelNameForRust(const Channel &channel) {
+ return channel.name();
+}
+inline rust::Str GetChannelNameForRust(const Channel &channel) {
+ return StringViewToRustStr(channel.name()->string_view());
+}
+
} // namespace aos::configuration
#endif // AOS_CONFIGURATION_FOR_RUST_H_