-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add Send + Sync
to common traits
#172
Add Send + Sync
to common traits
#172
Conversation
api/src/graph.rs
Outdated
@@ -53,7 +53,7 @@ pub trait Graph { | |||
where | |||
Self: 'x; | |||
/// The error type that this graph may raise. | |||
type Error: Error + 'static; | |||
type Error: Error + 'static + Send + Sync; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Knowing that this is a breaking change, I held off on explicitly feature flagging unless explicitly requested. This can easily be modified:
type Error: Error + 'static + Send + Sync; | |
#[cfg(not(feature = "threadsafe_errs"))] | |
type Error: Error + 'static; | |
#[cfg(feature = "threadsafe_errs")] | |
type Error: Error + 'static + Send + Sync; |
Thanks for this suggestion, it makes sense. However, I would like to check first whether it breaks badly some known implementations. I will check with mine. @KonradHoeffner (for |
@pchampin: Thanks for the heads-up! In HDT I have |
Works for |
Thanks for letting us know! I have implemented my errors following the official rust by examples docs given at https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/define_error_type.html It seems to be the recommended way to implement custom errors cleanly, and I am not a big fan of adding a whole dependency just for something as basic as handling errors (especially that the standard way to handle errors is quite nice and makes it clear which errors might be raised by the lib) I have tried to add
Do you have an idea of how we could add |
@vemonet I was thinking of making this a feature flag in #[cfg(not(feature = "threadsafe_err"))]
pub use std::error::Error;
#[cfg(feature = "threadsafe_err")]
pub use ThreadSafeError as Error;
pub trait ThreadSafeError: std::error::Error + Send + Sync + 'static {}
impl<E> ThreadSafeError for E where E: std::error::Error + Send + Sync + 'static {} then replace any |
I'm moving this PR to draft to implement the |
@pchampin I've implemented the |
@mkatychev Without the feature flag, I don't think that the alias |
4e146bb
to
47805e1
Compare
@pchampin I've reverted the flag changes, should be good to go |
Various error libraries have datastructures such as
anyhow::Error
that required the errors they hold to beSend + Sync
in addition to beingstd::error::Error
.The common traits below have had their
::Error
associated type further constraints to includeSend + Sync
:sophia_api::dataset::Dataset
sophia_api::graph::Graph
sophia_api::source::Source
sophia_api::term::TryFromTerm
sophia_inmem::index::TermIndex