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

Compile time errors on partially supported systems #81

Open
JOT85 opened this issue Jan 8, 2021 · 0 comments
Open

Compile time errors on partially supported systems #81

JOT85 opened this issue Jan 8, 2021 · 0 comments

Comments

@JOT85
Copy link
Contributor

JOT85 commented Jan 8, 2021

At the moment, the behaviour on partially systems is to return Err(Error::UnsupportedSystem). This error is therefore raised at runtime. If an error can be known at compile time, surely that's a better place to raise it?

I propose changing the design so that functions are only included for a system if they are supported on that system.

linux_os_release is a good example; it's only supported on Linux and yet any platform can call it, with the result always being Err(Error::UnsupportedSystem). An alternative approach would be to only compile linux_os_release on Linux systems so that trying to use it results in an error at compile time.

Another example would be os_release or cpu_speed, which aren't supported on Android.

In addition, on systems like iOS, which aren't formally supported, there are build errors - which isn't a great way to error out. Moreover, some functions, such as hostname are valid for all unix-like systems and so could be compiled for iOS (I can't test this claim). Not including functions that will cause errors means that someone can get the most out of the library on any system.

I'm happy to make these changes myself, I was wondering what other peoples thoughts were on such a change before I spent time working on it.

Thanks!

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

1 participant