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

Update inotify dependency from 0.10.0 to 0.11.0 #35

Merged
merged 4 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ anyhow = "1.0.65"
cfg-if = "1.0.0"

[target.'cfg(target_os = "linux")'.dependencies]
inotify = "0.10.0" # Watch files and auto-reload on changes
inotify = "0.11.0" # Watch files and auto-reload on changes

[target.'cfg(any(target_os="macos", target_os="dragonfly", target_os="freebsd", target_os="netbsd", target_os="openbsd"))'.dependencies]
kqueue = "1.0.6" # Watch files and auto-reload on changes
18 changes: 4 additions & 14 deletions src/file_watcher/inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ pub struct FileWatchImpl {

impl FileWatcherImpl {
pub fn init() -> Result<FileWatcherImpl> {
let ino = match Inotify::init() {
Ok(i) => i,
Err(msg) => return Result::Err(msg),
};
let ino = Inotify::init()?;

Result::Ok(FileWatcherImpl {
inotify: ino,
Expand All @@ -30,15 +27,11 @@ impl FileWatcherImpl {
pub fn add_watch(&mut self, file_path: &PathBuf) -> Result<&FileWatchImpl> {
let mask: inotify::WatchMask = inotify::WatchMask::MODIFY;

let watch = match self.inotify.watches().add(file_path, mask) {
Ok(w) => w,
Err(msg) => return Result::Err(msg),
};

let watch = self.inotify.watches().add(file_path, mask)?;
let fw = FileWatchImpl { descriptor: watch };

self.watches.push(fw);
return Result::Ok(self.watches.last().unwrap());
Result::Ok(self.watches.last().unwrap())
}

pub fn rm_watch(&mut self, fw: &FileWatchImpl) -> Result<()> {
Expand All @@ -62,10 +55,7 @@ impl FileWatcherImpl {

pub fn any_events(&mut self) -> Result<bool> {
let mut buffer = [0; 1024];
let events = match self.inotify.read_events(&mut buffer) {
Result::Ok(ev) => ev,
Result::Err(err) => return Result::Err(err),
};
let events = self.inotify.read_events(&mut buffer)?;

Result::Ok(events.count() > 0)
}
Expand Down
5 changes: 1 addition & 4 deletions src/file_watcher/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ pub struct FileWatchImpl {

impl FileWatcherImpl {
pub fn init() -> Result<FileWatcherImpl> {
let kq = match KQueue::new() {
Ok(value) => value,
Err(msg) => return Result::Err(msg),
};
let kq = KQueue::new()?;

Ok(FileWatcherImpl {
kq,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl<'a> Tui<'a> {
}
}

impl<'a> UiAgent for Tui<'a> {
impl UiAgent for Tui<'_> {
fn start(mut self) -> Result<ApplicationExitReason> {
// Setup event loop and input handling
let (tx, rx) = mpsc::channel();
Expand Down
Loading