{"id":20122873,"url":"https://github.com/freaky/keventdir-rs","last_synced_at":"2026-06-09T15:03:50.251Z","repository":{"id":142942532,"uuid":"148225234","full_name":"Freaky/keventdir-rs","owner":"Freaky","description":"Rust directory activity monitor for kevent systems","archived":false,"fork":false,"pushed_at":"2018-09-19T00:48:19.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T20:30:49.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Freaky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2018-09-10T22:09:26.000Z","updated_at":"2018-09-19T00:48:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"fcc26987-dacd-48e7-86cd-caf8438203c1","html_url":"https://github.com/Freaky/keventdir-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Freaky/keventdir-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fkeventdir-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fkeventdir-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fkeventdir-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fkeventdir-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Freaky","download_url":"https://codeload.github.com/Freaky/keventdir-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fkeventdir-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34112225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-13T19:41:35.062Z","updated_at":"2026-06-09T15:03:50.224Z","avatar_url":"https://github.com/Freaky.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KEventDir\n\nA simple kevent-driven directory watcher for Rust.\n\n## Synopsis\n\nCurrently more a proof-of-concept than a production-ready crate:\n\n```rust\nextern crate keventdir;\n\nuse keventdir::KEventDir;\n\nfn main() {\n    let watcher = KEventDir::new().expect(\"kqueue\");\n    watcher.add_recursive_rescan(\"content\"); // rescan this dir on file rename\n    watcher.rescan(); // actually add that directory, returning number of new files\n\n    // rename detection is only partial outside the base directory: old files are\n    // removed but only the base directory is checked for new ones.\n    watcher.add(\"config.toml\").expect(\"returns io::Result\"); // watch this one file\n    watcher.add_recursive(\"static\"); // watch this directory tree, returns number added\n\n    // KEventDir implements Iterator over io::Result\u003ckeventdir::Event\u003e\n    for ev in watcher.by_ref().filter_map(|ev| ev.ok()).take(10) {\n        println!(\"{}: {:?}\", ev.path.display(), ev.kind);\n    }\n\n    // You can also poll for events, either non-blocking or with a time limit\n    if let Some(ev) = watcher.poll(Some(Duration::from_secs(20))) {\n        let ev = ev.expect(\"kevent\");\n        println!(\"{}: {:?}\", ev.path.display(), ev.kind)\n    }\n}\n```\n\nCommands:\n\n```\n-% echo \"meep\" \u003e\u003econtent/meep\n-% rm content/meep\n-% echo \"woof\" \u003econtent/dogs\n-% mv content/{dogs,cats}\n-% echo \"meow\" \u003e\u003econtent/cats\n-% mv content/{cats,dogs}\n-% mkdir content/bam\n-% rmdir content/bam\n```\n\nOutput:\n\n```\ncontent: Write\ncontent: Write\ncontent/meep: Delete\ncontent: Write\ncontent: Write\ncontent/dogs: Rename\ncontent/cats: Write\ncontent: Write\ncontent/cats: Rename\ncontent: Link\ncontent: Link\ncontent/bam: Delete\n```\n\nI'm still pinning down a sensible API.  Renames and new file handling is less\nthan ideal, and it probably needs to be broken up into higher and lower-level\ninterfaces, one with basic efficient kqueue stuff and one with debounced events\nand more expensive stuff like adding new files on rename.\n\n## Status\n\nThis is just a quick proof-of-concept.  You might find it useful or interesting,\nbut if it breaks you get to keep all the pieces.\n\nUse [notify](https://github.com/passcod/notify) if you need to use something\nproduction-ready and portable, though note it currently uses polling on BSD's:\ni.e. it does a `walkdir` every few seconds.\n\n## Caveats\n\nkevent isn't really designed with monitoring large numbers of files in mind.\nEach and every file and directory to be monitored needs to be opened, and kept\nopen, because it operates on file descriptors, not file names.\n\nFor most typical use it's probably fine, but don't go adding `/` to it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreaky%2Fkeventdir-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreaky%2Fkeventdir-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreaky%2Fkeventdir-rs/lists"}