rust-x-bindings / rust-xcb

Rust bindings and wrapper for XCB.
MIT License
165 stars 64 forks source link

`xcb_connection_t` (and per extension `base::Connection`) are opaque #47

Closed ibabushkin closed 7 years ago

ibabushkin commented 7 years ago

From what I gather from the XCB docs, the xcb_connection_t struct is not opaque, at least it's members are well-documented. So it makes sense to allow access to (some of) it's members. That's especially useful if one needs access to the undelying file descriptor. Do you agree? If so, I could provide the code for that (as I recently discovered the need for such functionality).

rtbo commented 7 years ago

xcb_connection_t is opaque (as in the C API, so no direct member access is possible). It is defined as pub enum xcb_connection_t {}, which is how opaque types are defined in Rust. base::Connection is not opaque, but its members are private. They can be access through get_raw_conn() and get_raw_dpy() methods though. To access the file descriptor, (quite common use case if you need to poll on the connection), base::Connnection implements AsRawFd trait. (which calls xcb_get_file_descriptor). This is not in the docs however. It is published since v0.8.1.

ibabushkin commented 7 years ago

Hm, the xcb_connection_t docs don't look opaque to me :) - however, the AsRawFd implementation is all I need. So I suppose no further change should be necessary.

rtbo commented 7 years ago

I guess that is generated documentation from the private source code. In the public header, the struct is opaque.

ibabushkin commented 7 years ago

On 2017-10-27, Remi Thebault wrote:

I guess that is generated documentation from the private source code. In the public header, the struct is opaque.

Alright, my bad. Since we resolved the core issue though, I'll close this now.