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

use the new std::{fs, path} #5

Merged
merged 1 commit into from
Feb 15, 2015
Merged

use the new std::{fs, path} #5

merged 1 commit into from
Feb 15, 2015

Conversation

blaenk
Copy link
Contributor

@blaenk blaenk commented Feb 15, 2015

This also requires an updated inotify-rs which you can find in this branch (see the PR). It basically uses the new std::io for errors. You can use it like this:

[target.x86_64-unknown-linux-gnu.dependencies.inotify]
git = "git@github.com:blaenk/inotify-rs.git"
branch = "new-io"

So Path is to str as PathBuf is to String, as I'm sure you already know. So things that contained Paths, like HashMaps, now contain PathBufs.

One consequence of updating the inotify-rs package to use the new std::io is that there is no longer an EndOfFile variant of ErrorKind. Instead, read returns a 0 on EOF. I'm not sure exactly what should be done in this case, in the context of inotify, so in my inotify-rs branch I just returned an empty slice. This may change if you guys decide there's something else that should be done instead. Read the PR for more information.

One problem right now is that we forgot to implement Hash for Path; it's only implemented for PathBuf. This means that if you want to perform operations on a hashmap that contains PathBuf keys, but you only have a &Path, you have to convert it to a PathBuf in order to index the hashmap. I filed a PR for this for rust, and for now added FIXME comments so we can remember to change this when it lands.

One slightly tedious change is that fs::walk_dir now returns an iterator that itself yields Results. If the result is Ok, it yields a DirEntry type which you call path() on to get the actual Path.

As with my inotify-rs PR, I updated this to use the new std::io::Error instead of IoError.

Now, instead of lstat(), we use the metadata() method which has a modified() method which we can use.

@passcod
Copy link
Member

passcod commented Feb 15, 2015

Merging to get it building, but will await the inotify-rs PR to merge before releasing a crate.

passcod added a commit that referenced this pull request Feb 15, 2015
Update to latest Rust: use the new std::{fs, path}
@passcod passcod merged commit ffad89a into notify-rs:master Feb 15, 2015
@hannobraun
Copy link

FYI, I've just released the new version of inotify-rs to crates.io.

@passcod
Copy link
Member

passcod commented Feb 16, 2015

Great :) I'll do the release dance tonight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants