You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some naming inconsistencies that have been bothering me for a while, and I'd like to solicit input for anyone who has some. There is a mix of free functions that return structures, and constructor methods on structs. Some examples:
There's a free function process::all_processes() -> ProcResult<Vec<Process>> to get all processes, but a method Process::new(pid) -> ProcResult<Process> to get a single process
There's a free function cpuinfo() -> ProcResult<CpuInfo> to get CPU Info, but when getting memory info, you use a constructor method Meminfo::new() -> ProcResult<MemInfo>
My personal inclination is to remove the number of free functions (except when necessary, because there's no struct to attach to. boot_time_secs() -> ProcResult<u64> is a good example of this), but I'm curious to know if anyone else has any thoughts on this
The text was updated successfully, but these errors were encountered:
My two cents: cpuinfo() vs Meminfo::new() seems more inconsistent then process::all_processes() (You could argue that since there is no ProcessList struct it is a valid free function).
I maintain rust-psutil which follows the psutil API and we actually mostly just use free functions, the one exception being Process::new. One instance where this feels right is that we have some functions like cpu_times() which returns a CpuTimes and cpu_times_percpu which returns a Vec<CpuTimes>. I'm not really sure if there's a right answer to this one though, but the important part seems to probably be to have consistency across the project.
There are some naming inconsistencies that have been bothering me for a while, and I'd like to solicit input for anyone who has some. There is a mix of free functions that return structures, and constructor methods on structs. Some examples:
process::all_processes() -> ProcResult<Vec<Process>>
to get all processes, but a methodProcess::new(pid) -> ProcResult<Process>
to get a single processcpuinfo() -> ProcResult<CpuInfo>
to get CPU Info, but when getting memory info, you use a constructor methodMeminfo::new() -> ProcResult<MemInfo>
My personal inclination is to remove the number of free functions (except when necessary, because there's no struct to attach to.
boot_time_secs() -> ProcResult<u64>
is a good example of this), but I'm curious to know if anyone else has any thoughts on thisThe text was updated successfully, but these errors were encountered: