Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get the file descriptors for use with event loops #69

Closed
detly opened this issue Jun 21, 2021 · 5 comments
Closed

How do I get the file descriptors for use with event loops #69

detly opened this issue Jun 21, 2021 · 5 comments

Comments

@detly
Copy link
Contributor

detly commented Jun 21, 2021

I am trying to integrate rusb with the Calloop event loop. Usually this involves getting file descriptors for polling and adding them to the loop. Anything that implements AsRawFd works.

In my case I'm mainly interested in hotplug events, so I want the "whole-context" file descriptors that are available from the get_pollfds() call. Is there any (safe, preferably) way to get these?

@detly
Copy link
Contributor Author

detly commented Jun 27, 2021

I achieved this through using rusb as a submodule and getting at libusb1_sys within my own project. Do you have a particular opinion about whether libusb1_sys and its types (eg. libusb_pollfds) should be exposed or not?

@a1ien
Copy link
Owner

a1ien commented Jun 28, 2021

You can add both rusb and libusb1_sys as dependency to you project and directly use any function from libusb1_sys

[dependencies]
rusb = "0.8.1"
libusb1-sys = "0.5.0"
    unsafe {
        libusb1_sys::libusb_get_pollfds(std::ptr::null_mut());
    }

You don't need to add rusb as submodule to achieve this.

@detly
Copy link
Contributor Author

detly commented Jun 29, 2021

Won't this pull libusb1_sys from crates.io, which is based on the deprecated standalone repository?

@a1ien
Copy link
Owner

a1ien commented Jun 29, 2021

Yes. but it's must not be a problem.
P.S. As I say in #56 i add re-export for libusb1-sys. I think do this in couple of week and releasing major version with #72 and #71

@detly
Copy link
Contributor Author

detly commented Jun 29, 2021

Great, thanks!

@detly detly closed this as completed Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants