pub struct UeventListener { /* private fields */ }
Expand description
A listener for Linux udev events.
Implementations§
Source§impl UeventListener
impl UeventListener
Sourcepub fn new(driver: &impl SpawnDriver) -> Result<Self, NewUeventListenerError>
pub fn new(driver: &impl SpawnDriver) -> Result<Self, NewUeventListenerError>
Opens a new netlink socket and starts listening on it.
Sourcepub async fn add_custom_callback(
&self,
callback: impl 'static + Send + FnMut(Notification<'_>),
) -> CallbackHandle
pub async fn add_custom_callback( &self, callback: impl 'static + Send + FnMut(Notification<'_>), ) -> CallbackHandle
Adds a callback function that receives every event.
Sourcepub async fn add_block_resize_callback(
&self,
major: u32,
minor: u32,
notify: impl 'static + Send + FnMut(),
) -> CallbackHandle
pub async fn add_block_resize_callback( &self, major: u32, minor: u32, notify: impl 'static + Send + FnMut(), ) -> CallbackHandle
Adds a callback that runs when the block device with the given major/minor numbers has been resized or a rescan event was triggered where the caller is required to rescan for the condition
Sourcepub async fn wait_for_matching_child<T, F, Fut>(
&self,
path: &Path,
f: F,
) -> Result<T>
pub async fn wait_for_matching_child<T, F, Fut>( &self, path: &Path, f: F, ) -> Result<T>
Waits for a child of the provided devpath (typically something under /sys) to exist.
If it does not immediately exist, this will poll the path for existence each time a new uevent arrives.
f
will be called with the file name of the child, and a boolean: true
if the child was found by uevent, false if it was found by sysfs. It
should return Some(_)
if the child is the correct one.
This is inefficient if there are lots of waiters and lots of incoming uevents, but this is not an expected use case.
Sourcepub async fn wait_for_devpath(&self, path: &Path) -> Result<()>
pub async fn wait_for_devpath(&self, path: &Path) -> Result<()>
Waits for the provided devpath (typically something under /sys) to exist.
If it does not immediately exist, this will poll the path for existence each time a new uevent arrives.
This is inefficient if there are lots of waiters and lots of incoming uevents, but this is not an expected use case.