-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add AllUsers
and AllGroups
#11
Conversation
- Renamed `BiMap` to `IdNameMap` to better reflect its purpose - Extracted type parameters out of `IdNameMap` for ease of reuse - Added `IdNameMap::insert` for convenience - `UsersCache` now uses a single `RefCell` for both forward and backward maps; does not seem to break anything - Refactored methods that use `UsersCache::{users,groups}` accordingly - `UsersCache::default` is now implemented with `derive`; `HashMap` nonsense moved into the new `IdNameMap::default`
- Added `AllUsers` trait that provides `all_users()` - Added `UsersSnapshot` - user data is pre-loaded, not fetched lazily - implements `AllUsers` and `Users` - `MockUsers` now implements `AllUsers` exposing the list of added users - Equivalent group functionality NYI - Documentation not yet updated
I have stopped short of writing the groups code and updating docs because I'm not entirely sure this is the correct approach. An alternative implementation exists in make-iters-mockable, where So I decided to design Finally, I don't really like the name collision with the private return type of Please let me know what you think, and I'll finish the PR then. |
Sorry, for the late response, have been busy lately and I knew this would take a moment to read through properly ... especially with the two options. Anyway, this look very promising to me in general, thank you!
Hm, comparing both I gotta say the "dryer" version here looks a lot cleaner to me or much easier to understand at the very least. I'm not sure the potential performance benefits of the other version are worth the over-complication it introduces in the |
- Added `AllGroups` trait that provides `all_groups()` - `UsersSnapshot` now implements `Groups` and `AllGroups` - `MockUsers` now implements `AllGroups` - `UsersSnapshot::filtered` not yet updated: adds all groups - Documentation not yet updated
`UsersSnapshot::filtered` has been split into two new methods to accomodate the two probable use cases: - `::filtered` now accepts a separate filter for groups - `::only_users` only accepts groups that are some included user's primary group.
- Documentation of `UsersCache` was moved from module to the struct itself to keep the module doc from bloating to a billion lines. - Description of `UsersCache` in crate doc shortened slightly as it is no longer the only solution.
|
Signed-off-by: Sandro-Alessio Gierens <sandro@gierens.de>
c08cd11
to
f373229
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very sorry it took me so long to get back to you! ... Again, thanks! LGTM! ... I added a deprecation warning to UsersCache::with_all_users()
for the upcoming minor version and reworded one of the commit messages a little. With that it should be ready for merge now!
AllUsers
andAllGroups
are traits that provideall_users()
andall_groups()
similar to howUsers
andGroups
provide other library functions. Also included isUsersSnapshot
, a pre-loaded version ofUsersCache
that can iterate over its contents safely.MockUsers
now also implementsAllUsers
andAllGroups
.Resolves #10.
Example usage
Checklist:
AllUsers
AllGroups
UsersSnapshot
MockUsers