Make all error types Send + Sync#625
Open
atro7318 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I am trying to use this library for calling the Zitadel API in a multi-threaded environment, thus I need all error types to be
Send + Sync. Making errorsSend + Syncis also recommended as a Rust API best practice. See the second through fourth paragraphs from this section:I first tried to use the currently used
custom_errordependency, but it seems to only supportBox<dyn Error>, notBox<dyn Error + Send + Sync + 'static>. I instead switched all of the error type definitions in this repo to be annotated withthiserrorderive and attribute macros. I then changed all usages ofBox<dyn Error>toBox<dyn Error + Send + Sync + 'static>and got rid of thecustom_errordependency. I believe this solution minimizes boilerplate just as well ascustom_error, allows for writing more code in plain Rust (rather than function-like macros), and allows for this repo's dependency on a much more widely adopted and maintained crate (thiserror).If you agree, merging and releasing this change would be very useful for my work. Thank you.