How to get UniquePtr<EnumMember> on the Rust side?

Using the cxx crate: https://crates.io/crates/cxx

I have the following struct on Rust:


#[cxx::bridge]
pub(crate) mod ffi {
    enum SizeType {
        BYTE,
        WORD,
        DWORD,
        QWORD,
    }
     unsafe extern "C++" {
         //...
     }
}

which is also mapped on C++. How do I get UniquePtr<SizeType> on Rust? Do I have to write a C++ function to get it? If I do, there's no point in having the struct on the Rust side.

I tried

let byte_ptr = UniquePtr::new(SizeType::BYTE);

but it does not work.

Specifically how?

the trait bound bridge::ffi::SizeType: cxx::memory::UniquePtrTarget is not satisfied
the trait cxx::memory::UniquePtrTarget is not implemented for bridge::ffi::SizeType

According to the docs, you have to explicitly request that impl.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.