Rust编程语言的惯用语intify包装器。-Rust开发

  • F4_255993
    了解作者
  • 25.5KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-24 06:20
    上传日期
inotify-rs Rust编程语言的惯用语inotify包装器。 木箱化 inotify-rs Rust编程语言的惯用语inotify包装器。 木箱化 使用std :: env; 使用inotify :: {EventMask,WatchMask,Inotify,}; fn main(){let mut inotify = Inotify :: init().expect(“初始化inotify失败”); 让current_dir = env :: current_dir().expect(“无法确定当前目录”); inotify .add_watch(current_dir,WatchMask :: MODIFY | WatchMask :: CREATE | WatchMask :: DE
inotify-rs-master.zip
  • inotify-rs-master
  • .github
  • workflows
  • rust.yml
    618B
  • src
  • fd_guard.rs
    1.7KB
  • util.rs
    1KB
  • inotify.rs
    16.8KB
  • events.rs
    14.6KB
  • watches.rs
    11.1KB
  • lib.rs
    2.8KB
  • stream.rs
    3KB
  • examples
  • watch.rs
    1.6KB
  • stream.rs
    836B
  • tests
  • main.rs
    7KB
  • Cargo.toml
    1.2KB
  • inotify-rs.sublime-project
    89B
  • CONTRIBUTING.md
    1.5KB
  • LICENSE
    741B
  • README.md
    4.2KB
  • .gitignore
    48B
  • CHANGELOG.md
    2.5KB
内容介绍
# 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) [![Build Status](https://travis-ci.org/inotify-rs/inotify.svg?branch=master)](https://travis-ci.org/hannobraun/inotify-rs) Idiomatic [inotify] wrapper for the [Rust programming language]. ```Rust extern crate inotify; use std::env; use inotify::{ EventMask, WatchMask, Inotify, }; fn main() { let mut inotify = Inotify::init() .expect("Failed to initialize inotify"); let current_dir = env::current_dir() .expect("Failed to determine current directory"); inotify .add_watch( current_dir, WatchMask::MODIFY | WatchMask::CREATE | WatchMask::DELETE, ) .expect("Failed to add inotify watch"); println!("Watching current directory for activity..."); let mut buffer = [0u8; 4096]; loop { let events = inotify .read_events_blocking(&mut buffer) .expect("Failed to read inotify events"); for event in events { if event.mask.contains(EventMask::CREATE) { if event.mask.contains(EventMask::ISDIR) { println!("Directory created: {:?}", event.name); } else { println!("File created: {:?}", event.name); } } else if event.mask.contains(EventMask::DELETE) { if event.mask.contains(EventMask::ISDIR) { println!("Directory deleted: {:?}", event.name); } else { println!("File deleted: {:?}", event.name); } } else if event.mask.contains(EventMask::MODIFY) { if event.mask.contains(EventMask::ISDIR) { println!("Directory modified: {:?}", event.name); } else { println!("File modified: {:?}", event.name); } } } } } ``` ## Usage Include it in your `Cargo.toml`: ```toml [dependencies] inotify = "0.9" ``` Please refer to the [documentation] and the example above, for information on how to use it in your code. Please 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]. If you need to access inotify in a way that this wrapper doesn't support, consider using [inotify-sys] instead. ## Documentation The 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. Additional examples can be found in the **[examples directory]**. Please 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. ## License Copyright (c) Hanno Braun and contributors Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. [inotify]: http://en.wikipedia.org/wiki/Inotify [Rust programming language]: http://rust-lang.org/ [documentation]: https://docs.rs/inotify [notify]: https://crates.io/crates/notify [inotify-sys]: https://crates.io/crates/inotify-sys [API reference]: https://docs.rs/inotify [examples directory]: https://github.com/inotify-rs/inotify/tree/master/examples [inotify man page]: http://man7.org/linux/man-pages/man7/inotify.7.html
评论
    相关推荐
    • rusti:Rust编程语言的REPL
      rusti:Rust编程语言的REPL
    • learn-rust, 帮助我学习 Rust 编程语言的项目.zip
      learn-rust, 帮助我学习 Rust 编程语言的项目 通过面试问题学习 Rust这个reposity是我第一次认真尝试学习 Rust的产品。我没有一个特别的probem来处理,所以我使用了工作面试编码问题在互联网上找到。 特别是,"黑了...
    • 用于Rust编程语言的GLFW绑定和包装器。-Rust开发
      glfw-rs Rust编程语言的GLFW绑定和包装。 示例extern crate glfw; 使用glfw :: {Action,Context,Key}; fn main(){le glfw-rs Rust编程语言的GLFW绑定和包装。 示例extern crate glfw; 使用glfw :: {Action,...
    • learning-rust:通过rust编程语言pdf进行工作
      学习锈 这是处理rust文档.pdf的回购
    • rust-koans:Rust编程语言的Koans
      鲁斯特·科恩斯(Rust Koans) 结构 koans按文件划分为多个区域,arrays.rs中覆盖了数组,booleans.rs中引入了布尔值,等等。它们在path_to_enlightenment.rs文件中按顺序显示。 每个koan都会建立您对Rust的知识并...
    • 图书:Rust编程语言
      Rust编程语言 该存储库包含“ The Rust Programming Language”这本书的源代码。 。 您还可以免费在线阅读该书。 请参阅该书随附的最新, 或Rust版本。 请注意,这些版本中的问题可能已经在此存储库中修复,因为...
    • 使用rust编程语言深入研究攻击性安全-抢先体验-Rust开发
      使用锈编程语言深入研究进攻性安全-抢先体验Black Hat Rust-抢先使用Rust编程语言深入研究进攻性安全立即购买本书! 总结无论是在电影中还是在主流媒体中,黑客都经常被浪漫化:他们被描绘成黑魔法师,讨厌的罪犯,...
    • the-book:Rust编程语言代码
      通用编程概念 3.1。变量与可变性 3.2。资料类型 3.3。功能 3.4。评论 3.5。控制流 4.了解所有权 4.1。什么是所有权? 4.2。参考和借阅 4.3。切片类型 5.使用结构来构造相关数据 5.1。定义和实例化结构 5.2。使用...
    • learning-rust:此仓库用于学习rust编程语言
      learning-rust:此仓库用于学习rust编程语言
    • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
      guassdb100在redhat上安装包,单机部署的包,安装步骤请看我的文中介绍,经过大量实验搭建总结出来的文档