Skip to content

Commit

Permalink
Implement most setters as a Rust struct
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Feb 5, 2025
1 parent 46ba4ca commit 04bdb41
Show file tree
Hide file tree
Showing 4 changed files with 640 additions and 359 deletions.
2 changes: 1 addition & 1 deletion include/mbgl/util/tile_server_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class TileServerOptions final {
TileServerOptions& withDefaultStyles(std::vector<mbgl::util::DefaultStyle> styles);

/**
* @brief Sets the default style by name. The style name must exists in
* @brief Sets the default style by name. The style name must exist in
* defaultStyles collection
*
* @param defaultStyle The style name
Expand Down
47 changes: 47 additions & 0 deletions platform/rust/include/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,52 @@ inline const int8_t* TileServerOptions_tileVersionPrefix(const TileServerOptions
return get_raw_str_ptr(self.tileVersionPrefix());
}

// TileServerOptions setters
inline void TileServerOptions_withBaseURL(TileServerOptions& self, const rust::Str value) {
self.withBaseURL((std::string)value);
}
inline void TileServerOptions_withUriSchemeAlias(TileServerOptions& self, const rust::Str value) {
self.withUriSchemeAlias((std::string)value);
}
inline void TileServerOptions_withSourceTemplate(TileServerOptions& self, const rust::Str source_template, const rust::Str domain_name, const int8_t* version_prefix) {
self.withSourceTemplate(
(std::string)source_template,
(std::string)domain_name,
(version_prefix ? std::string((const char*)version_prefix) : std::optional<std::string>{}));
}
inline void TileServerOptions_withStyleTemplate(TileServerOptions& self, const rust::Str style_template, const rust::Str domain_name, const int8_t* version_prefix) {
self.withStyleTemplate(
(std::string)style_template,
(std::string)domain_name,
(version_prefix ? std::string((const char*)version_prefix) : std::optional<std::string>{}));
}
inline void TileServerOptions_withSpritesTemplate(TileServerOptions& self, const rust::Str sprites_template, const rust::Str domain_name, const int8_t* version_prefix) {
self.withSpritesTemplate(
(std::string)sprites_template,
(std::string)domain_name,
(version_prefix ? std::string((const char*)version_prefix) : std::optional<std::string>{}));
}
inline void TileServerOptions_withGlyphsTemplate(TileServerOptions& self, const rust::Str glyphs_template, const rust::Str domain_name, const int8_t* version_prefix) {
self.withGlyphsTemplate(
(std::string)glyphs_template,
(std::string)domain_name,
(version_prefix ? std::string((const char*)version_prefix) : std::optional<std::string>{}));
}
inline void TileServerOptions_withTileTemplate(TileServerOptions& self, const rust::Str tile_template, const rust::Str domain_name, const int8_t* version_prefix) {
self.withTileTemplate(
(std::string)tile_template,
(std::string)domain_name,
(version_prefix ? std::string((const char*)version_prefix) : std::optional<std::string>{}));
}
inline void TileServerOptions_withApiKeyParameterName(TileServerOptions& self, const rust::Str value) {
self.withApiKeyParameterName((std::string)value);
}
inline void TileServerOptions_setRequiresApiKey(TileServerOptions& self, bool value) {
self.setRequiresApiKey(value);
}
inline void TileServerOptions_withDefaultStyle(TileServerOptions& self, const rust::Str value) {
self.withDefaultStyle((std::string)value);
}

} // namespace bridge
} // namespace ml
Loading

0 comments on commit 04bdb41

Please sign in to comment.