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

Add Send + Sync to common traits #172

Merged
merged 22 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub trait Dataset {
where
Self: 'x;
/// The error type that this dataset may raise.
type Error: Error + 'static;
type Error: Error + 'static + Send + Sync;

/// An iterator visiting all quads of this dataset in arbitrary order.
///
Expand Down
2 changes: 1 addition & 1 deletion api/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor Author

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:

Suggested change
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;


/// An iterator visiting all triples of this graph in arbitrary order.
///
Expand Down
4 changes: 2 additions & 2 deletions api/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub trait Source {
/// The type of items this source yields.
type Item<'x>;
/// The type of errors produced by this source.
type Error: Error + 'static;
type Error: Error + 'static + Send + Sync;

/// Call f for some item(s) (possibly zero) from this source, if any.
///
Expand Down Expand Up @@ -200,7 +200,7 @@ pub trait Source {
impl<'a, I, T, E> Source for I
where
I: Iterator<Item = Result<T, E>> + 'a,
E: Error + 'static,
E: Error + 'static + Send + Sync,
{
type Item<'x> = T;
type Error = E;
Expand Down
2 changes: 1 addition & 1 deletion api/src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ pub trait FromTerm: Sized {
/// See also [`FromTerm`]
pub trait TryFromTerm: Sized {
/// The error type produced when failing to copy a given term
type Error: 'static + std::error::Error;
type Error: 'static + std::error::Error + Send + Sync;
/// Try to copy `term` into an instance of this type.
fn try_from_term<T: Term>(term: T) -> Result<Self, Self::Error>;
}
Expand Down
4 changes: 2 additions & 2 deletions inmem/src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use _iter::*;

/// A dataset with a single quad index (GSPO).
/// Fast to load but slow on some queries, with a relatively low memory footprint.
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct GenericLightDataset<TI: TermIndex> {
terms: TI,
quads: BTreeSet<[TI::Index; 4]>,
Expand Down Expand Up @@ -194,7 +194,7 @@ impl<TI: GraphNameIndex> SetDataset for GenericLightDataset<TI> {}

/// A heavily indexed dataset.
/// Fast to query but slow to load, with a relatively high memory footprint.
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct GenericFastDataset<TI: GraphNameIndex> {
terms: TI,
gspo: BTreeSet<[TI::Index; 4]>,
Expand Down
2 changes: 1 addition & 1 deletion inmem/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub trait TermIndex {
/// The type of [indices](Index) used by this [`TermIndex`]
type Index: Index;
/// The type of error that this [`TermIndex`] may raise
type Error: Error + 'static;
type Error: Error + 'static + Send + Sync;

/// Get the index corresponding to term `t`, if it exists.
///
Expand Down
6 changes: 3 additions & 3 deletions rio/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct StrictRioTripleSource<T>(pub T);
impl<T> sophia_api::source::Source for StrictRioTripleSource<T>
where
T: rio_api::parser::TriplesParser,
T::Error: Error + 'static,
T::Error: Error + 'static + Send + Sync,
{
type Item<'x> = Trusted<rio_api::model::Triple<'x>>;

Expand Down Expand Up @@ -50,7 +50,7 @@ pub struct StrictRioQuadSource<T>(pub T);
impl<T> sophia_api::source::Source for StrictRioQuadSource<T>
where
T: rio_api::parser::QuadsParser,
T::Error: Error + 'static,
T::Error: Error + 'static + Send + Sync,
{
type Item<'x> = Trusted<rio_api::model::Quad<'x>>;

Expand Down Expand Up @@ -83,7 +83,7 @@ pub struct GeneralizedRioSource<T>(pub T);
impl<T> sophia_api::source::Source for GeneralizedRioSource<T>
where
T: rio_api::parser::GeneralizedQuadsParser,
T::Error: Error + 'static,
T::Error: Error + 'static + Send + Sync,
{
type Item<'x> = Trusted<rio_api::model::GeneralizedQuad<'x>>;

Expand Down