Commit Graph

6 Commits

Author SHA1 Message Date
Ben S fefddc4a76 Replace User fields with getters
The name() accessor is able to hide the fact that the user's actual name string is hidden in an Arc. (The Arc is still available, since it's needed for caching)
2016-01-28 15:04:22 +00:00
Ben S 107e0aee7b Add example that makes sure it works everywhere 2016-01-28 14:07:31 +00:00
Ben S 77eefe0176 Rename OSUsers to UsersCache
It's more descriptive to call it a cache when there are functions that do all the *actual* OS users stuff separately now.

Similarly, we may as well call its constructor 'new' instead of 'empty_cache', because it's obvious that it's a cache now.
2016-01-26 19:17:24 +00:00
Benjamin Sago 052cf245f4 Split Users trait into Users and Groups traits
It was getting crowded in there! Not only are two groups of six easier to manage than one group of twelve, but the groups functions didn't actually have anything to do with users...
2016-01-14 23:15:53 -10:00
Benjamin Sago aa94ee89db Return Arcs instead of clones, and take &self
The primary goal of this commit was to avoid having to clone the users and groups it produces. The old implementation was written by me when I hadn't *fully* internalised how lifetimes worked, and just used `clone` to get around the error messages. It was only later that I realised how inefficient this actually is -- the values stored in the cache are never used, only their clones are!

Several attempt at this later, I settled on using `Arc` for everything and cloning *those* values instead.

All the gory details of what happened are written in a comment in the OS module. The short version is that it's now possible to change the `Users` trait's methods from taking `&mut self` to just taking `&self`. This is within the allowed uses of `Cell`: implementation details of a method that does actually return the same thing each time, which this is.

The main casualty is that the user now has to know about `Arc` and initialise a user with a username in such a container, which I hope to solve in a later commit.
2016-01-14 23:15:02 -10:00
Ben S 336223239a Initial import 2014-12-12 10:36:17 +00:00