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

Provide API to get only specific directory #72

Open
Shatur opened this issue Mar 21, 2022 · 4 comments
Open

Provide API to get only specific directory #72

Shatur opened this issue Mar 21, 2022 · 4 comments

Comments

@Shatur
Copy link

Shatur commented Mar 21, 2022

With dirs crate I can get any directory directly. But directories provides structs and parses all directories at once. Users usually want to get a single directory. I would suggest to create separate functions as in dirs crate.

@soc
Copy link
Collaborator

soc commented Mar 24, 2022

Hey Hennadii,

the intention of this design was to allow a user to create this struct once with the right parameters for the given application and then be able to use the derived paths for the applications' needs, while having the guarantee that all paths where computed consistently (i. e. at the same time during the construction of struct).

In the case only a single directory is needed, it's perfectly fine to use dirs instead.

What's the source of your concerns?

Cheers,

Simon

@Shatur
Copy link
Author

Shatur commented Mar 25, 2022

the intention of this design was to allow a user to create this struct once with the right parameters

But I most of the application doesn't need all of them. This is why I suggested to allow to get directories separately. Or evaluate directories lazily.

In the case only a single directory is needed, it's perfectly fine to use dirs instead.

dirs is great. But this crate provides project directories which I need.

I recently discovered standard_paths crate which have the described design. So if you disagree with the suggestion - feel free to close the issue.

@soc
Copy link
Collaborator

soc commented Mar 25, 2022

But I most of the application doesn't need all of them. This is why I suggested to allow to get directories separately. Or evaluate directories lazily.

As soon as applications use more than one, it should already be cost-effective, because the expensive operations are only executed once.

I recently discovered standard_paths crate which have the described design. So if you disagree with the suggestion - feel free to close the issue.

Not sure I understand, that crate appears to be using roughly the approach. Am I missing something?

@Shatur
Copy link
Author

Shatur commented Mar 25, 2022

As soon as applications use more than one, it should already be cost-effective, because the expensive operations are only executed once.

You doing it once, but you create a structure with 7 directories when usually an application need 1-2. I would also create it once, but with needed directories.

Not sure I understand, that crate appears to be using roughly the approach. Am I missing something?

I just mentioned that I already found a library (was in the README) that allow to find only specified directories as I suggested.

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

No branches or pull requests

2 participants