Skip to content

Commit

Permalink
implement TileServerOptions instantiation and access
Browse files Browse the repository at this point in the history
BUG: the optional<str> access returns junk
  • Loading branch information
nyurik committed Jan 30, 2025
1 parent 567cf09 commit b9644a8
Show file tree
Hide file tree
Showing 5 changed files with 398 additions and 3 deletions.
3 changes: 3 additions & 0 deletions platform/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition = "2021"
cxx = "1.0"
clap = { version = "4.5.27", features = ["derive", "env"] }

[dev-dependencies]
insta = { version = "1.42.1" }

[build-dependencies]
cmake = "0.1"
cxx-build = "1.0"
Expand Down
17 changes: 17 additions & 0 deletions platform/rust/include/wrapper.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
#pragma once
#include "rust/cxx.h"
#include "mbgl/math/log2.hpp"
#include "mbgl/util/tile_server_options.hpp"

namespace ml {
namespace rust {

uint32_t get_42();

using namespace mbgl;

// TileServerOptions constructor helpers
std::unique_ptr<TileServerOptions> TileServerOptions_new();
std::unique_ptr<TileServerOptions> TileServerOptions_default();
std::unique_ptr<TileServerOptions> TileServerOptions_mapbox();
std::unique_ptr<TileServerOptions> TileServerOptions_maplibre();
std::unique_ptr<TileServerOptions> TileServerOptions_maptiler();

// TileServerOptions Optional<string> helpers (not supported yet by cxx)
const int8_t * TileServerOptions_sourceVersionPrefix(const TileServerOptions& self);
const int8_t * TileServerOptions_styleVersionPrefix(const TileServerOptions& self);
const int8_t * TileServerOptions_spritesVersionPrefix(const TileServerOptions& self);
const int8_t * TileServerOptions_glyphsVersionPrefix(const TileServerOptions& self);
const int8_t * TileServerOptions_tileVersionPrefix(const TileServerOptions& self);

} // namespace rust
} // namespace ml
4 changes: 4 additions & 0 deletions platform/rust/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ fmt:
test:
cargo test --all-targets --workspace

# Run all tests and accept the changes. Requires cargo-insta to be installed.
test-accept:
cargo insta test --accept

# Test documentation
test-doc:
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
Expand Down
Loading

0 comments on commit b9644a8

Please sign in to comment.