rust-crates / ergo_fs

ergonomic filesystem operations in rust
https://docs.rs/ergo_fs
Other
7 stars 0 forks source link

Disjointed ways of finding files #13

Open epage opened 6 years ago

epage commented 6 years ago

(Originally on reddit)

In looking at the holistic API

epage commented 6 years ago

One concern raised on reddit for wrapping walkdir is the very nature of wrapping it. For a higher-level, ergonomic API, do we need to expose the full power of the API? I feel like we can assume the users of the library are already sacrificing performance for ergonomics. walkdir on the other hand was heavily designed for performance. This provides a way for alternatively exposing walkdir in a simple way that integrates with the rest of the crate.

vitiral commented 6 years ago

Glob and walkdir feel like appendages to the API rather than

I think you didn't complete this sentance 😃

Glob and walkdir fill similar purposes

I agree with this to an extent. The main reason that glob exists is because we are targeting the CLI space and globs are ubiquitous for CLIs. That's also why we have shellexpand.

For a higher-level, ergonomic API, do we need to expose the full power of the [walkdir] API?

I actually hadn't considered this. In some ways the only APIs we need are:

This is really all I have needed for some pretty complex applications. Sorting the output, breadth-first, etc are not often needed features and while the filter function theoretically improves ergonomics I've found it actually quite difficult to use effectively (quite often you depend on outside state and it ends up being annoying to handle the lifetimes correctly).

epage commented 6 years ago

Starting from requirements, which you just gave, I think will be important for this. I think another good angle is "what do other high level APIs do" (Python's pathlib being the one I'm most familiar with but they intentionally left functionality off of it like walk and shutil).

I think what you listed works well.