Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Feb 5, 2025
1 parent 63774c6 commit 4ae4a5b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
2 changes: 1 addition & 1 deletion platform/rust/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ docs:
cargo doc --no-deps --open

# Print Rust version information
rust-info:
@rust-info:
rustc --version
cargo --version

Expand Down
33 changes: 16 additions & 17 deletions platform/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub use tile_server_options::TileServerOptions;

#[cxx::bridge(namespace = "ml::bridge")]
mod ffi {
// C++ types exposed to Rust.
unsafe extern "C++" {
include!("maplibre-native/include/wrapper.h");

Expand All @@ -16,70 +15,70 @@ mod ffi {
fn TileServerOptions_maptiler() -> UniquePtr<TileServerOptions>;

fn TileServerOptions_withBaseURL(obj: Pin<&mut TileServerOptions>, value: &str);
fn baseURL(self: &TileServerOptions) -> &CxxString;
fn baseURL(&self) -> &CxxString;
fn TileServerOptions_withUriSchemeAlias(obj: Pin<&mut TileServerOptions>, value: &str);
fn uriSchemeAlias(self: &TileServerOptions) -> &CxxString;
fn uriSchemeAlias(&self) -> &CxxString;
unsafe fn TileServerOptions_withSourceTemplate(
obj: Pin<&mut TileServerOptions>,
source_template: &str,
domain_name: &str,
version_prefix: *const i8,
);
fn sourceTemplate(self: &TileServerOptions) -> &CxxString;
fn sourceDomainName(self: &TileServerOptions) -> &CxxString;
fn sourceTemplate(&self) -> &CxxString;
fn sourceDomainName(&self) -> &CxxString;
unsafe fn TileServerOptions_sourceVersionPrefix(value: &TileServerOptions) -> *const i8;
unsafe fn TileServerOptions_withStyleTemplate(
obj: Pin<&mut TileServerOptions>,
style_template: &str,
domain_name: &str,
version_prefix: *const i8,
);
fn styleTemplate(self: &TileServerOptions) -> &CxxString;
fn styleDomainName(self: &TileServerOptions) -> &CxxString;
fn styleTemplate(&self) -> &CxxString;
fn styleDomainName(&self) -> &CxxString;
unsafe fn TileServerOptions_styleVersionPrefix(value: &TileServerOptions) -> *const i8;
unsafe fn TileServerOptions_withSpritesTemplate(
obj: Pin<&mut TileServerOptions>,
sprites_template: &str,
domain_name: &str,
version_prefix: *const i8,
);
fn spritesTemplate(self: &TileServerOptions) -> &CxxString;
fn spritesDomainName(self: &TileServerOptions) -> &CxxString;
fn spritesTemplate(&self) -> &CxxString;
fn spritesDomainName(&self) -> &CxxString;
unsafe fn TileServerOptions_spritesVersionPrefix(value: &TileServerOptions) -> *const i8;
unsafe fn TileServerOptions_withGlyphsTemplate(
obj: Pin<&mut TileServerOptions>,
glyphs_template: &str,
domain_name: &str,
version_prefix: *const i8,
);
fn glyphsTemplate(self: &TileServerOptions) -> &CxxString;
fn glyphsDomainName(self: &TileServerOptions) -> &CxxString;
fn glyphsTemplate(&self) -> &CxxString;
fn glyphsDomainName(&self) -> &CxxString;
unsafe fn TileServerOptions_glyphsVersionPrefix(value: &TileServerOptions) -> *const i8;
unsafe fn TileServerOptions_withTileTemplate(
obj: Pin<&mut TileServerOptions>,
tile_template: &str,
domain_name: &str,
version_prefix: *const i8,
);
fn tileTemplate(self: &TileServerOptions) -> &CxxString;
fn tileDomainName(self: &TileServerOptions) -> &CxxString;
fn tileTemplate(&self) -> &CxxString;
fn tileDomainName(&self) -> &CxxString;
unsafe fn TileServerOptions_tileVersionPrefix(value: &TileServerOptions) -> *const i8;
unsafe fn TileServerOptions_withApiKeyParameterName(
obj: Pin<&mut TileServerOptions>,
value: &str,
);
fn apiKeyParameterName(self: &TileServerOptions) -> &CxxString;
fn apiKeyParameterName(&self) -> &CxxString;
fn TileServerOptions_setRequiresApiKey(obj: Pin<&mut TileServerOptions>, value: bool);
fn requiresApiKey(self: &TileServerOptions) -> bool;
fn requiresApiKey(&self) -> bool;

// /// Gets the default styles.
// const std::vector<mbgl::util::DefaultStyle> defaultStyles() const;

// /// Sets the collection default styles.
// TileServerOptions& withDefaultStyles(std::vector<mbgl::util::DefaultStyle> styles);

// fn withDefaultStyle(self: &TileServerOptions);
// fn withDefaultStyle(&self);
unsafe fn TileServerOptions_withDefaultStyle(obj: Pin<&mut TileServerOptions>, value: &str);
fn defaultStyle(self: &TileServerOptions) -> &CxxString;
fn defaultStyle(&self) -> &CxxString;
}
}
4 changes: 2 additions & 2 deletions platform/rust/src/tile_server_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub struct TileServerOptions(UniquePtr<ffi::TileServerOptions>);
/// # Safety
/// * as_ptr() inside C++ std::string is guaranteed to be null-terminated.
/// * The &CStr will remain valid as long as the TileServerOptions `&self` remains valid.
/// If some code tries to modify self, it will need to use &mut self,
/// which will not compile unless there are no &CStr references, as they use the same lifetime.
/// If some code tries to modify self, it will need to use &mut self,
/// which will not compile unless there are no &CStr references, as they use the same lifetime.
unsafe fn to_c_str(value: &CxxString) -> &CStr {
CStr::from_ptr(value.as_ptr().cast())
}
Expand Down
4 changes: 0 additions & 4 deletions platform/rust/src/wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@
namespace ml {
namespace bridge {

uint32_t get_42() {
return 42;
}

} // namespace bridge
} // namespace ml

0 comments on commit 4ae4a5b

Please sign in to comment.