cr8t / udev

Pure Rust interface to the userspace devfs (udev) subsystem on Linux
GNU General Public License v2.0
4 stars 1 forks source link

feature: Configure blocking or polling mode #18

Open cr8t opened 5 months ago

cr8t commented 5 months ago

From https://github.com/cr8t/udev/issues/15#issuecomment-1913190142:

// for lack of an easy way to set it to blocking mode or poll

There should be an easy way to configure the UdevMonitor, and other udevrs modules to use blocking/polling mode.

What is a good design-choice for implementing a non-blocking mode that is agnostic to async/threading/etc.?

cr8t commented 5 months ago

@kevinmehall could you provide some feedback on what would be useful for you in nusb?

@CertainLach what would be most helpful in your use-case?

kevinmehall commented 5 months ago

I'd recommend defaulting the socket to blocking mode so it "just works" but allow interoperating with async runtimes without requiring any one of them. Implement the std AsFd and AsRawFd traits, and make sure it passes through ErrorKind::WouldBlock results from the socket. Then users can wrap it in an async-io's Async<T> or Tokio AsyncFd to integrate it with their event loops.