Skip to content

Implement AsRawFd for Device #77

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ryankurte
Copy link
Contributor

provides compatibility with smol::Async for polling from async contexts:

// Setup async device wrapper (configures device file descriptor with `O_NONBLOCK`)
let a = smol::Async::new(d)?;

// Async poll for the next event
let (_status, event) = a.read_with(|d| d.next_event(ReadFlag::NORMAL) ).await?;

for convenience Device also really needs to be Sync, which it is not automatically due to the internal *mut raw::libevdev, however, i can't see from the evdev docs whether this is reasonable or not?

provides compatibility with `smol::Async` for async use.
@ndesh26
Copy link
Owner

ndesh26 commented Nov 28, 2021

I haven't used Sync myself before so I need to look into it a bit more. Other things look good to me.

@ryankurte
Copy link
Contributor Author

having another look at this it appears y'all already have interior mutability with raw: *mut raw::libevdev so the borrow checker will allow multiple references which all can be (internally) mutated and adding Sync would let this occur across threads, which could expound any existing unsoundness.

i am however not sure how to mitigate this :-/

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

Successfully merging this pull request may close these issues.

2 participants