dope_uring/watch/mod.rs
1use std::{ffi::CStr, os::fd};
2
3use o3::base::marker::ThreadBound;
4
5pub use dope_sys::io::file::watch::Event;
6pub mod raw;
7
8#[repr(transparent)]
9pub struct Watch {
10 file: fd::OwnedFd,
11 thread: ThreadBound,
12}
13
14impl Watch {
15 /// Observes moved-in entries and invalidation of one fixed directory.
16 pub fn try_new(path: &CStr) -> Result<Self, dope_sys::Errno> {
17 Ok(Self {
18 file: raw::create(path)?,
19 thread: ThreadBound::NEW,
20 })
21 }
22}
23
24impl fd::AsFd for Watch {
25 fn as_fd(&self) -> fd::BorrowedFd<'_> {
26 self.file.as_fd()
27 }
28}