{"id":13439991,"url":"https://github.com/hannobraun/inotify-rs","last_synced_at":"2025-12-12T16:52:02.372Z","repository":{"id":15894972,"uuid":"18636332","full_name":"hannobraun/inotify-rs","owner":"hannobraun","description":"Idiomatic inotify wrapper for the Rust programming language","archived":false,"fork":false,"pushed_at":"2024-09-18T08:39:36.000Z","size":413,"stargazers_count":261,"open_issues_count":10,"forks_count":65,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-10-29T16:22:05.257Z","etag":null,"topics":["inotify","linux","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hannobraun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-10T12:53:33.000Z","updated_at":"2024-10-20T15:43:33.000Z","dependencies_parsed_at":"2024-11-05T18:02:33.273Z","dependency_job_id":"5000d4bd-5973-4167-ac6e-e23b6a2ca232","html_url":"https://github.com/hannobraun/inotify-rs","commit_stats":{"total_commits":458,"total_committers":58,"mean_commits":7.896551724137931,"dds":0.7139737991266375,"last_synced_commit":"3022fb5ac25e65375f9c7110999d29966e4292b4"},"previous_names":["hannobraun/inotify"],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hannobraun%2Finotify-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hannobraun%2Finotify-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hannobraun%2Finotify-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hannobraun%2Finotify-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hannobraun","download_url":"https://codeload.github.com/hannobraun/inotify-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["inotify","linux","rust"],"created_at":"2024-07-31T03:01:18.796Z","updated_at":"2025-12-12T16:51:57.348Z","avatar_url":"https://github.com/hannobraun.png","language":"Rust","funding_links":[],"categories":["Libraries","库 Libraries"],"sub_categories":["Platform specific","特定于平台的 Platform specific"],"readme":"# inotify-rs [![crates.io](https://img.shields.io/crates/v/inotify.svg)](https://crates.io/crates/inotify) [![Documentation](https://docs.rs/inotify/badge.svg)](https://docs.rs/inotify) [![Rust](https://github.com/hannobraun/inotify-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/hannobraun/inotify-rs/actions/workflows/rust.yml)\n\n## Introduce\nIdiomatic [inotify] wrapper for the [Rust programming language].This package generally tries to adhere to the underlying inotify API closely, while making access to it safe and convenient.\n\n## Examples\nNow inotify-rs supports synchronous or asynchronous event monitoring.\nAn example of synchronous is as follows:\n```rs\nuse inotify::{EventMask, Inotify, WatchMask};\nuse std::env;\n\nfn main() {\n    let mut inotify = Inotify::init().expect(\"Failed to initialize inotify\");\n\n    let current_dir = env::current_dir().expect(\"Failed to determine current directory\");\n\n    inotify\n        .watches()\n        .add(\n            current_dir,\n            WatchMask::MODIFY | WatchMask::CREATE | WatchMask::DELETE,\n        )\n        .expect(\"Failed to add inotify watch\");\n\n    println!(\"Watching current directory for activity...\");\n\n    let mut buffer = [0u8; 4096];\n    loop {\n        let events = inotify\n            .read_events_blocking(\u0026mut buffer)\n            .expect(\"Failed to read inotify events\");\n\n        for event in events {\n            if event.mask.contains(EventMask::CREATE) {\n                if event.mask.contains(EventMask::ISDIR) {\n                    println!(\"Directory created: {:?}\", event.name);\n                } else {\n                    println!(\"File created: {:?}\", event.name);\n                }\n            } else if event.mask.contains(EventMask::DELETE) {\n                if event.mask.contains(EventMask::ISDIR) {\n                    println!(\"Directory deleted: {:?}\", event.name);\n                } else {\n                    println!(\"File deleted: {:?}\", event.name);\n                }\n            } else if event.mask.contains(EventMask::MODIFY) {\n                if event.mask.contains(EventMask::ISDIR) {\n                    println!(\"Directory modified: {:?}\", event.name);\n                } else {\n                    println!(\"File modified: {:?}\", event.name);\n                }\n            }\n        }\n    }\n}\n```\nPerhaps you want asynchronous monitoring of events.An example of asynchronous is as follows:\n```rs\nuse std::{fs::File, io, thread, time::Duration};\n\nuse futures_util::StreamExt;\nuse inotify::{Inotify, WatchMask};\nuse tempfile::TempDir;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), io::Error\u003e {\n    let inotify = Inotify::init().expect(\"Failed to initialize inotify\");\n\n    let dir = TempDir::new()?;\n    // Watch for modify and create events.\n    inotify\n        .watches()\n        .add(dir.path(), WatchMask::CREATE | WatchMask::MODIFY)?;\n    // Create a thread to operate on the target directory\n    thread::spawn::\u003c_, Result\u003c(), io::Error\u003e\u003e(move || loop {\n        File::create(dir.path().join(\"file\"))?;\n        thread::sleep(Duration::from_millis(500));\n    });\n\n    let mut buffer = [0; 1024];\n    let mut stream = inotify.into_event_stream(\u0026mut buffer)?;\n    // Read events from async stream\n    while let Some(event_or_error) = stream.next().await {\n        println!(\"event: {:?}\", event_or_error?);\n    }\n\n    Ok(())\n}\n\n\n```\n\n## Usage\n\nAdd the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\ninotify = \"0.11\"\n```\n\nPlease refer to the [documentation] and the example above, for information on how to use it in your code.\n\n## Notice \nPlease note that inotify-rs is a relatively low-level wrapper around the original inotify API. And, of course, it is Linux-specific, just like inotify itself. If you are looking for a higher-level and platform-independent file system notification library, please consider **[notify]**.\n\nIf you need to access inotify in a way that this wrapper doesn't support, consider using **[inotify-sys]** instead.\n\n## Documentation\n\nThe most important piece of documentation for inotify-rs is the **[API reference]**, as it contains a thorough description of the complete API, as well as examples.\n\nAdditional examples can be found in the **[examples directory]**.\n\nPlease also make sure to read the **[inotify man page]**. Inotify use can be hard to get right, and this low-level wrapper won't protect you from all mistakes.\n\n## License\n\nCopyright (c) Hanno Braun and contributors\n\nPermission to use, copy, modify, and/or distribute this software for any purpose\nwith or without fee is hereby granted, provided that the above copyright notice\nand this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\nOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\nTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n[inotify]: http://en.wikipedia.org/wiki/Inotify\n[Rust programming language]: http://rust-lang.org/\n[documentation]: https://docs.rs/inotify\n[notify]: https://crates.io/crates/notify\n[inotify-sys]: https://crates.io/crates/inotify-sys\n[API reference]: https://docs.rs/inotify\n[examples directory]: https://github.com/inotify-rs/inotify/tree/main/examples\n[inotify man page]: http://man7.org/linux/man-pages/man7/inotify.7.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhannobraun%2Finotify-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhannobraun%2Finotify-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhannobraun%2Finotify-rs/lists"}