Conversation
Adds a Pages newtype over u64 for type-safe storage of quantities of memory pages. Mark /proc/buddyinfo as supported.
|
Sorry for taking so long to review this. It looks good to me. I don't understand the CI failures, and they happened so long ago that I can't retry them.
There is some precedent for this, for example in the rss_bytes API. I don't love this type of API because with the current separation of |
| } | ||
| } | ||
|
|
||
| wrap_numeric!(Pages, u64, "A quantity of pages of memory"); |
There was a problem hiding this comment.
I think this is missing some bits for handling the serde stuff:
error[E0277]: the trait bound `types::Pages: Deserialize<'_>` is not satisfied
--> procfs-core/src/buddyinfo.rs:20:18
|
20 | free_chunks: HashMap<Pages, u64>,
| ^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `types::Pages`
Added parsing code for
/proc/buddyinfo, and unit tests for the parser.Also added a
Pagestype overu64to make it more obvious that the data in/proc/buddyinfo/is measured in terms of memory pages and not bytes, kilobytes or anything else, rather than making the parsing code also query the system page size. I'm a little torn about whether or not to add conversions eg. fromPagestousizethat factor in the current system page size, or leave it up to the API consumer.