Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about a special case #1404

Open
sirandreww opened this issue Nov 19, 2024 · 0 comments
Open

Question about a special case #1404

sirandreww opened this issue Nov 19, 2024 · 0 comments

Comments

@sirandreww
Copy link

I'm implementing rust bindings for a the C++ API that is available here.
I'm struggling to figure out how best to convert a specific pattern.
The C++ code has this structure:
Type V is pure virtual (=0 after one of its methods) and is used almost like a trait in rust. Where a function is made generic by accepting this type.
Type A has a method that takes an object of type V, this method stores this object for later use.

For a concrete example, here is an example of V:

class Terminator {
public:
  virtual ~Terminator () {}
  virtual bool terminate () = 0;
};

And this is a reduced example of the object A:

class Solver {
  ...
  void connect_terminator (Terminator *terminator);
  void disconnect_terminator ();
}

How do you think I can create a safe rust FFI for a pattern like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant