scylladb / scylladb/cpp-rs-driver

Deduplicate bindgen-generated entities

Open
#399 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
26
Forks
19
Avg merge
1d 21h
Merged PRs (30d)
7

Description

We currently use bindgen to create a considerable number of .rs modules. The idea is to call bindgen many times with a narrow list of whitelisted types. No types are listed multiple times, so each type should appear in one corresponding module and be use'able from there.

This is unfortunately not true because of allowlist transitivity: if a type is in the allowlists and it depends on another type, that type is added to the allowlist. This results in multiple distinct Rust types that correspond to the same C type, with the important example of CassInet: it appears both in cppdriver_inet_types.rs and cppdriver_host_listener_types.rs. Those types are distinct even though identical, and implementation for both must be duplicated.

To solve this, I suggest writing the bindings to a single .rs module. Later, to group things more sensibly instead of having them in one big bag, it's possible to re-export them from different modules as previously.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the bindgen generation setup and the generated modules, especially cppdriver_inet_types.rs and cppdriver_host_listener_types.rs, where CassInet is duplicated. Confirm how allowlist transitivity creates repeated Rust types, then make the generated bindings use one shared module while preserving access to the entities from their intended modules.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.