Description
Hello,
I'm using rust-bindgen
to generate bindings for libcouchbase. It works fine in general, but I noticed that for example this typedef enum:
typedef enum {
LCB_KV_COPY = 0, /**< The buffer should be copied */
LCB_KV_CONTIG, /**< The buffer is contiguous and should not be copied */
LCB_KV_IOV, /**< The buffer is not contiguous and should not be copied */
/**For use within the hashkey field, indicates that the _length_
* of the hashkey is the vBucket ID, rather than an actual hashkey */
LCB_KV_VBID,
/**
* The buffers are not contiguous (multi-part buffers) but should be
* copied. This avoids having to make the buffers contiguous before
* passing it into the library (only to have the library copy it again) */
LCB_KV_IOVCOPY
} lcb_KVBUFTYPE;
Gets abstracted as _bindgen_ty_10
and then a type alias of type lcb_KVBUFTYPE = _bindgen_ty_10;
is defined as well. It wouldn't be much of an issue (other than making the rustdoc very noisy since there are many similar types), but then later on in the code I can't pattern match/use the enum variants because of rust-lang/rust#26264 directly.
As a result, I end up writing _bindgen_ty_10::LCB_KV_COPY
which defeats the purpose of the alias mostly.
So, is there either a workaround or an option to avoid this indirection and just name the enums/structs directly after what they are called in C code?
Note that this can be easily reproduced by cloning and building https://github.com/couchbaselabs/couchbase-rs/tree/master/couchbase-sys, and I'm happy to help getting it to run :)
Thanks!