blob: c01ef5752e1cb97fa31fc52a939873c93c9e88fc [file] [log] [blame]
Brian Silverman7edd1ce2022-07-23 16:10:54 -07001#ifndef AOS_CONFIGURATION_FOR_RUST_H_
2#define AOS_CONFIGURATION_FOR_RUST_H_
3
Brian Silverman6d499362022-08-18 17:50:46 -07004#include <optional>
5
Brian Silverman7edd1ce2022-07-23 16:10:54 -07006#include "aos/configuration.h"
Brian Silverman6d499362022-08-18 17:50:46 -07007#include "aos/for_rust.h"
Brian Silverman7edd1ce2022-07-23 16:10:54 -07008#include "cxx.h"
9
10namespace aos::configuration {
11
12const Channel *GetChannelForRust(const Configuration *config, rust::Str name,
13 rust::Str type, rust::Str application_name,
14 const Node *node);
15
Brian Silverman67cdbd62022-08-15 06:03:55 -070016const Node *GetNodeForRust(const Configuration *config, rust::Str name);
17
Brian Silverman7edd1ce2022-07-23 16:10:54 -070018// Returns a Configuration flatbuffer. Returns an empty vector on errors.
Brian Silverman67cdbd62022-08-15 06:03:55 -070019// TODO(Brian): It would be nice to return more detailed errors (not found vs
20// could not parse vs merging error).
Brian Silverman7edd1ce2022-07-23 16:10:54 -070021rust::Vec<uint8_t> MaybeReadConfigForRust(
22 rust::Str path, rust::Slice<const rust::Str> extra_import_paths);
23
Brian Silverman6d499362022-08-18 17:50:46 -070024inline bool HasChannelTypeForRust(const Channel &channel) {
25 return channel.type();
26}
27inline rust::Str GetChannelTypeForRust(const Channel &channel) {
28 return StringViewToRustStr(channel.type()->string_view());
29}
30
31inline bool HasChannelNameForRust(const Channel &channel) {
32 return channel.name();
33}
34inline rust::Str GetChannelNameForRust(const Channel &channel) {
35 return StringViewToRustStr(channel.name()->string_view());
36}
37
Brian Silverman7edd1ce2022-07-23 16:10:54 -070038} // namespace aos::configuration
39
40#endif // AOS_CONFIGURATION_FOR_RUST_H_