-
Notifications
You must be signed in to change notification settings - Fork 157
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
Study alternate designs for warnings #52
Comments
Started playing around with this a bit. The EfiResult ternary logic seems to model the problem most accurately, but it has several big things going against it:
For this reason, I'm now experimenting with an alternate design which is less elegant, but much easier to integrate in the existing Rust error handling ecosystem: // All names are open to bikeshedding
enum Completion<T> {
Success(T),
Warning(T, Status),
}
type Result<T> = core::Result<Completion<T>, Status>; With some careful From and Into impls, it looks like this could be made ergonomic enough... but I need to experiment some more to be sure. |
@HadrienG2 Interesting. First, would it be a better idea to have a separate How is this going to fit in with the existing Try trait implementation we're using for |
As far as I know, the semantics of warnings in UEFI are that the operation mostly completed as intended (and therefore mostly produced the expected result), but some unforeseen event happened along the way. Existing standard warnings describe...
From this perspective, it makes sense that the result type be homogeneous. The warning does not fundamentally change the result, it only notifies that some non-fatal failure occurred along the way. I'm currently trying to port the uefi-rs codebase to this design to see how well it works in practice. With added support to There are two limitations that emerge though, but they are not specific to this design:
Once I'm reasonably satisfied with the port, I will submit a PR, it will be easier to discuss around that 😄 |
On a side note, this |
As discussed in #51 , I think EFI warnings should be exposed as part of regular results, rather than as errors. We should, however, make them must_use to hint the user into checking them.
Another option would be to replace core::Result with a more elaborate enum that uses ternary logic:
But we would then need to duplicate a small amount of Result code and API and to think about how this will integrate with the Try (?) operator. I think a promising avenue for the latter would be to print a warning to the logs as part of into_result.
In any case, a problem to be resolved is that EFI purposely does not define which operations may throw a warning and which may not. So any solution must be generalizable to the whole EFI API surface with minimal boilerplate.
The text was updated successfully, but these errors were encountered: