Closed ghost closed 7 years ago
@tomaka
For plan A you should keep in mind that some systems don't have X11, so that should be detectable.
There would be functions to check the availability of libraries and functions, so you can avoid calling missing functions and causing a panic. Probably something like:
pub enum Lib {
Xlib,
Glx,
...
}
pub fn check_lib (lib: Lib) -> bool { ... }
pub fn check_fn (lib: Lib, fname: &str) -> bool { ... }
pub fn check_fns (lib: Lib, fnames: &[&str]) -> bool { ... }
One of the current problems is that Ubuntu LTS 14.04 has an older version of Xrandr which is missing 5 of the functions defined in x11::xrandr::Xrandr
, so we added a separate struct (x11::xrandr::Xrandr_2_2_0
) which omits these functions. Both plans described above will have better ways to avoid this problem.
I'm wondering if perhaps x11-dl could also be made just a feature of the main x11
crate? It mostly uses the same code anyway, and this way the code sharing could be better IMO. Of course this would be a breaking change, that's why I'm adding this comment to the version 3 thread.
My current plan is to define all types in x11
and pub use
them into x11-dl
when version 3.0 comes around. I think this may even be possible before 3.0 without breaking anything.
A suggestion for version 3:
Include some more bindings for xfixes
extension if possible.
Like winapi-rs
bindings are currently being added by hand, which is why things are missing. If xfixes
bindings are needed, I'll see if I have some time to add them. Unfortunately, version 3 may have to wait for untagged unions, or else a version 4 would follow shortly after.
Edit (20 October 2016): I'm working on a generator using clang. There will be a major restructure. The
x11
crate will have function bindings moved into a separate crate calledx11-static
whilex11
will only contain only types and constants (similar to thewinapi
crate). Bothx11-static
andx11-dl
will depend onx11
for these items so there will no longer be duplicates.x11-generator
will be a build dependency to generate the function bindings and will be available for custom bindings as well.x11
andx11-generator
will be built usingx11-parser
, which scans the C headers to generate bindings. The code generated byx11-parser
will be commited to the repository, so the C headers won't have to be present when building the Rust bindings.I am considering changing
x11-dl
to use lazy initialization. This will prevent the loader functions from failing if there are missing functions in order to avoid versioned structs. Instead, calling a missing function will cause a panic.Note: Version 3 probably won't be stable until untagged unions are a stable feature in Rust.