Skip to content

Shared Type Question #330

@scott-wilson

Description

@scott-wilson

Hey, this may not be the right direction to go, but feel free to correct me.

I am wrapping a C++ library, and they've defined a struct like this:

struct Thing {
    unsigned char someenum;
}

I want to be able to directly access the struct with a Rust struct like this:

enum SomeEnum {
    A,
    B,
    C
}
struct Thing {
    someenum: SomeEnum,
}

As a test, I've tried doing something like this:

#[cxx::bridge]
mod ffi {
    enum SomeEnum {
        A,
        B,
        C,
    }

    struct Thing {
        someenum: SomeEnum,
    }
}

unsafe impl cxx::ExternType for ffi::Thing {
    type Id = cxx::type_id!("Thing");
}

But I'm probably misunderstanding how ExternType works.

Either way, is this (or something like this) possible to do in cxx currently (or will be possible in the near future)?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions