Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for fast ops to fail at any (sync) phase. If a fallible fast op returns an Err variant, the fallback option will be set true and the error gets saved to
OpState
. V8 will immediately, synchronously call the normal binding function, and the#[op]
macro takes care of injecting a check for saved errors at the top of the binding.The op macro and especially its fast side is starting to get pretty ugly, and this makes it uglier still. Big points of ugliness and undefined behaviour:
OpState
borrowing is done several times at worst. There is no combined logic to figure out ifOpState
is needed and if it is needed as shared or unique (mut), thus leading to multiple places needing to borrow it individually.FastApiCallbackOptions
is starting to get quite confused about when it should be added into the inputs.Option<&mut FastApiCallbackOptions>
parameter AND returns aResult
or usesOpState
, then the macro will generate two mutable borrows or one mutable and one shared borrow for theFastApiCallbackOptions
, breaking Rust rules. This is likely "safe" in that its currently not used anywhere and its unlikely that it could lead to any issues since this is all synchronous code and thus race conditions are not possible. Still, it's not correct and shouldn't really be like this.A further point that should be pondered is if it's correct to add
fast_op_error
intoOpState
or if it would be better to just use the gotham state with some core, or perhapsops/lib.rs
, definedFastOpError(Err)
type.