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

Improve the error struct #11

Open
roblabla opened this issue Mar 10, 2018 · 0 comments
Open

Improve the error struct #11

roblabla opened this issue Mar 10, 2018 · 0 comments

Comments

@roblabla
Copy link
Member

roblabla commented Mar 10, 2018

Right now, our errors are wrapped into a rust newtype: https://github.com/roblabla/megaton-hammer/blob/master/megaton-hammer/src/lib.rs#L56

There are several additions we should do to it:

  1. This should probably be #[repr(transparent)]
  2. By using https://doc.rust-lang.org/core/nonzero/struct.NonZero.html and a constructor, we could make errors look like Option<Error>, while still being internally represented as a single u32, retaining binary compatibility (and thus being truly zero-overhead). Then, we could have all the svcs return an Option<Error>, giving us the ability to pattern match over its result.
    • TODO: Check if Result<(), Error> would be represented as a single u32 as well. If it is, then that's even better!
  3. We should have an enum of Modules (see http://switchbrew.org/index.php?title=Error_codes#Modules), which we can then stringify. In fact, maybe we should bitfieldify the error code ? Using something similar to https://github.com/roblabla/megaton-hammer/blob/master/megaton-hammer/src/ipc/mod.rs#L25
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