From d5be5334e0f76eebd8263e37870b46ebfb7738f6 Mon Sep 17 00:00:00 2001 From: Mikhail Katychev Date: Tue, 30 Jul 2024 07:49:45 -0500 Subject: [PATCH] Add `Send + Sync` to common traits (#172) also fix some clippy warnings --- api/src/dataset.rs | 9 ++++++--- api/src/dataset/adapter.rs | 2 ++ api/src/graph.rs | 9 ++++++--- api/src/serializer.rs | 4 ++-- api/src/source.rs | 14 ++++++-------- api/src/source/_quad.rs | 6 ++++-- api/src/source/_stream_error.rs | 4 ++-- api/src/source/_triple.rs | 6 ++++-- api/src/source/convert.rs | 4 ++-- api/src/source/filter.rs | 10 +++++----- api/src/source/filter_map.rs | 4 ++-- api/src/source/map.rs | 4 ++-- api/src/sparql.rs | 5 +++-- api/src/term.rs | 2 +- api/src/term/_simple.rs | 2 +- c14n/src/lib.rs | 2 +- c14n/src/rdfc10.rs | 4 ++-- inmem/src/index.rs | 3 ++- isomorphism/src/test.rs | 3 ++- jsonld/src/parser/source.rs | 2 +- resource/src/loader/_error.rs | 2 +- resource/src/resource/_error.rs | 19 ++++++++++++++----- rio/src/parser.rs | 23 ++++++++++++----------- rio/src/serializer.rs | 2 ++ turtle/src/serializer/_pretty.rs | 10 +++++----- turtle/src/serializer/trig.rs | 6 ++++-- turtle/src/serializer/turtle.rs | 5 +++-- 27 files changed, 97 insertions(+), 69 deletions(-) diff --git a/api/src/dataset.rs b/api/src/dataset.rs index 81878d5a..ac7c9b80 100644 --- a/api/src/dataset.rs +++ b/api/src/dataset.rs @@ -7,13 +7,15 @@ //! for different kinds of datasets, //! as well as a few implementations for them. +use std::error::Error; + use crate::graph::adapter::{DatasetGraph, PartialUnionGraph, UnionGraph}; use crate::quad::{iter_spog, Quad}; use crate::source::{IntoSource, QuadSource, StreamResult}; use crate::term::matcher::{GraphNameMatcher, TermMatcher}; use crate::term::{GraphName, SimpleTerm, Term}; + use resiter::{filter::*, filter_map::*, flat_map::*, map::*}; -use std::error::Error; mod _foreign_impl; pub mod adapter; @@ -56,7 +58,7 @@ pub trait Dataset { where Self: 'x; /// The error type that this dataset may raise. - type Error: Error + 'static; + type Error: Error + Send + Sync + 'static; /// An iterator visiting all quads of this dataset in arbitrary order. /// @@ -346,7 +348,7 @@ pub type MdResult = std::result::Result::Mutation /// see also [`SetDataset`]. pub trait MutableDataset: Dataset { /// The error type that this dataset may raise during mutations. - type MutationError: Error + 'static; + type MutationError: Error + Send + Sync + 'static; /// Insert the given quad in this dataset. /// @@ -609,6 +611,7 @@ mod check_implementability { /// - a list of terms (either atoms or index of quad) /// - a list of triples (SPO indexes) /// - a list of named graphs associated the triple indexes contained in the graph + /// /// This avoids the need to store arbitrarily nested triples. /// NB: unasserted triples are not used in any quoted graph. use super::*; diff --git a/api/src/dataset/adapter.rs b/api/src/dataset/adapter.rs index 7c86783c..f4f01889 100644 --- a/api/src/dataset/adapter.rs +++ b/api/src/dataset/adapter.rs @@ -1,4 +1,6 @@ //! I define adapters for the [`dataset`](super) related traits. +use std::error::Error; + use super::*; use crate::graph::{GTerm, Graph, MutableGraph}; use crate::quad::Spog; diff --git a/api/src/graph.rs b/api/src/graph.rs index f94432c6..64755ee9 100644 --- a/api/src/graph.rs +++ b/api/src/graph.rs @@ -5,12 +5,14 @@ //! for different kinds of graph, //! as well as a few implementations for them. +use std::error::Error; + use crate::dataset::adapter::GraphAsDataset; use crate::source::{IntoSource, StreamResult, TripleSource}; use crate::term::{matcher::TermMatcher, SimpleTerm, Term}; use crate::triple::Triple; + use resiter::{filter::*, flat_map::*, map::*}; -use std::error::Error; mod _foreign_impl; pub mod adapter; @@ -53,7 +55,7 @@ pub trait Graph { where Self: 'x; /// The error type that this graph may raise. - type Error: Error + 'static; + type Error: Error + Send + Sync + 'static; /// An iterator visiting all triples of this graph in arbitrary order. /// @@ -305,7 +307,7 @@ pub type MgResult = std::result::Result::MutationEr /// see also [`SetGraph`]. pub trait MutableGraph: Graph { /// The error type that this graph may raise during mutations. - type MutationError: Error + 'static; + type MutationError: Error + Send + Sync + 'static; /// Insert in this graph a triple made of the the given terms. /// @@ -530,6 +532,7 @@ mod check_implementability { /// where the graph maintains /// - a list of terms (either atoms or index of triple) /// - a list of triples (SPO indexes, plus an 'asserted' flag) + /// /// This avoids the need to store arbitrarily nested triples. use super::*; use crate::term::SimpleTerm; diff --git a/api/src/serializer.rs b/api/src/serializer.rs index 4b368f41..c87f0daa 100644 --- a/api/src/serializer.rs +++ b/api/src/serializer.rs @@ -18,7 +18,7 @@ use crate::source::*; /// A triple serializer writes triples according to a given format. pub trait TripleSerializer { /// The error type that may be raised during serialization. - type Error: 'static + std::error::Error; + type Error: std::error::Error + Send + Sync + 'static; /// Serialize all triples from the given [`TripleSource`]. fn serialize_triples( @@ -47,7 +47,7 @@ pub trait TripleSerializer { /// A quad serializer writes quads according to a given format. pub trait QuadSerializer { /// The error type that may be raised during serialization. - type Error: 'static + std::error::Error; + type Error: std::error::Error + Send + Sync + 'static; /// Serialize all quads from the given [`QuadSource`]. fn serialize_quads( diff --git a/api/src/source.rs b/api/src/source.rs index a90219a2..44381e8d 100644 --- a/api/src/source.rs +++ b/api/src/source.rs @@ -56,8 +56,6 @@ //! [`for_each_quad`]: QuadSource::for_each_quad //! [higher-rank trait bounds]: https://doc.rust-lang.org/nomicon/hrtb.html -use std::error::Error; - pub mod convert; pub mod filter; pub mod filter_map; @@ -70,7 +68,7 @@ pub use _stream_error::*; mod _triple; pub use _triple::*; -use std::convert::Infallible; +use std::{convert::Infallible, error::Error}; /// A source produces [items](Source::Item), and may also fail in the process. /// @@ -87,7 +85,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 + Send + Sync + 'static; /// Call f for some item(s) (possibly zero) from this source, if any. /// @@ -96,7 +94,7 @@ pub trait Source { /// Return an error if either the source or `f` errs. fn try_for_some_item(&mut self, f: F) -> StreamResult where - E: Error, + E: Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), E>; /// Call f for all items from this source. @@ -106,7 +104,7 @@ pub trait Source { fn try_for_each_item(&mut self, mut f: F) -> StreamResult<(), Self::Error, E> where F: FnMut(Self::Item<'_>) -> Result<(), E>, - E: Error, + E: Error + Send + Sync + 'static, { while self.try_for_some_item(&mut f)? {} Ok(()) @@ -200,14 +198,14 @@ pub trait Source { impl<'a, I, T, E> Source for I where I: Iterator> + 'a, - E: Error + 'static, + E: Error + Send + Sync + 'static, { type Item<'x> = T; type Error = E; fn try_for_some_item(&mut self, mut f: F) -> StreamResult where - E2: Error, + E2: Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), E2>, { match self.next() { diff --git a/api/src/source/_quad.rs b/api/src/source/_quad.rs index 468a1486..e5a48290 100644 --- a/api/src/source/_quad.rs +++ b/api/src/source/_quad.rs @@ -1,3 +1,5 @@ +use std::error::Error; + use super::*; use crate::dataset::{CollectibleDataset, Dataset, MutableDataset}; use crate::quad::Quad; @@ -20,7 +22,7 @@ pub trait QuadSource: Source + IsQuadSource { #[inline] fn try_for_some_quad(&mut self, mut f: F) -> StreamResult where - E: Error, + E: Error + Send + Sync + 'static, F: FnMut(Self::Quad<'_>) -> Result<(), E>, { self.try_for_some_item(|i| f(Self::i2q(i))) @@ -33,7 +35,7 @@ pub trait QuadSource: Source + IsQuadSource { fn try_for_each_quad(&mut self, mut f: F) -> StreamResult<(), Self::Error, E> where F: FnMut(Self::Quad<'_>) -> Result<(), E>, - E: Error, + E: Error + Send + Sync + 'static, { self.try_for_each_item(|i| f(Self::i2q(i))) } diff --git a/api/src/source/_stream_error.rs b/api/src/source/_stream_error.rs index 5550c4f0..f738d922 100644 --- a/api/src/source/_stream_error.rs +++ b/api/src/source/_stream_error.rs @@ -1,5 +1,3 @@ -use std::error::Error; - /// A error that is raised by functions that move fallible `Source`s into /// fallible `Sinks`. /// @@ -24,6 +22,8 @@ where #[error("Sink failed: {0}")] SinkError(#[source] SinkErr), } +use std::error::Error; + pub use StreamError::*; impl StreamError diff --git a/api/src/source/_triple.rs b/api/src/source/_triple.rs index f90dedef..0f80c192 100644 --- a/api/src/source/_triple.rs +++ b/api/src/source/_triple.rs @@ -1,3 +1,5 @@ +use std::error::Error; + use super::*; use crate::graph::{CollectibleGraph, Graph, MutableGraph}; use crate::triple::Triple; @@ -20,7 +22,7 @@ pub trait TripleSource: Source + IsTripleSource { #[inline] fn try_for_some_triple(&mut self, mut f: F) -> StreamResult where - E: Error, + E: Error + Send + Sync + 'static, F: FnMut(TSTriple) -> Result<(), E>, { self.try_for_some_item(|i| f(Self::i2t(i))) @@ -33,7 +35,7 @@ pub trait TripleSource: Source + IsTripleSource { fn try_for_each_triple(&mut self, mut f: F) -> StreamResult<(), Self::Error, E> where F: FnMut(TSTriple) -> Result<(), E>, - E: Error, + E: Error + Send + Sync + 'static, { self.try_for_each_item(|i| f(Self::i2t(i))) } diff --git a/api/src/source/convert.rs b/api/src/source/convert.rs index 90c9184e..a2b574f1 100644 --- a/api/src/source/convert.rs +++ b/api/src/source/convert.rs @@ -16,7 +16,7 @@ impl Source for ToQuads { fn try_for_some_item(&mut self, mut f: F) -> super::StreamResult where - E: std::error::Error, + E: std::error::Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), E>, { self.0.try_for_some_triple(|t| { @@ -40,7 +40,7 @@ impl Source for ToTriples { fn try_for_some_item(&mut self, mut f: F) -> super::StreamResult where - E: std::error::Error, + E: std::error::Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), E>, { self.0.try_for_some_quad(|q| { diff --git a/api/src/source/filter.rs b/api/src/source/filter.rs index de68e4b8..61550d14 100644 --- a/api/src/source/filter.rs +++ b/api/src/source/filter.rs @@ -22,7 +22,7 @@ where fn try_for_some_item(&mut self, mut f: F) -> StreamResult where - E: Error, + E: std::error::Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), E>, { let p = &mut self.predicate; @@ -55,7 +55,7 @@ mod _triple { fn try_for_some_item(&mut self, mut f: F) -> StreamResult where - E: Error, + E: std::error::Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), E>, { self.0.try_for_some_item(|i| f(S::i2t(i))) @@ -84,7 +84,7 @@ mod _quad { fn try_for_some_item(&mut self, mut f: F) -> StreamResult where - E: Error, + E: std::error::Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), E>, { self.0.try_for_some_item(|i| f(S::i2q(i))) @@ -130,7 +130,7 @@ mod test { ]; let mut h: Vec<[SimpleTerm; 3]> = vec![]; g.triples() - .filter_triples(|t| !Term::eq(t.p(), &ez_term(":e"))) + .filter_triples(|t| !Term::eq(t.p(), ez_term(":e"))) .for_each_triple(|t| { h.insert_triple(t).unwrap(); }) @@ -153,7 +153,7 @@ mod test { ]; let mut h: Vec> = vec![]; d.quads() - .filter_quads(|q| !Term::eq(q.p(), &ez_term(":e"))) + .filter_quads(|q| !Term::eq(q.p(), ez_term(":e"))) .for_each_quad(|q| { h.insert_quad(q).unwrap(); }) diff --git a/api/src/source/filter_map.rs b/api/src/source/filter_map.rs index d8057009..0f3a3e78 100644 --- a/api/src/source/filter_map.rs +++ b/api/src/source/filter_map.rs @@ -1,6 +1,6 @@ //! I define [`FilterMapSource`] the result type of [`Source::filter_map_items`]. use super::*; -use std::collections::VecDeque; +use std::{collections::VecDeque, error::Error}; /// The result of [`Source::filter_map_items`]. pub struct FilterMapSource { @@ -18,7 +18,7 @@ where fn try_for_some_item(&mut self, mut f: F2) -> StreamResult where - E: Error, + E: Error + Send + Sync + 'static, F2: FnMut(Self::Item<'_>) -> Result<(), E>, { let filter_map = &mut self.filter_map; diff --git a/api/src/source/map.rs b/api/src/source/map.rs index d6f21bfc..9bdd3511 100644 --- a/api/src/source/map.rs +++ b/api/src/source/map.rs @@ -1,6 +1,6 @@ //! I define [`MapSource`], the result type of [`Source::map_items`]. use super::*; -use std::collections::VecDeque; +use std::{collections::VecDeque, error::Error}; /// The result of [`Source::map_items`]. pub struct MapSource { @@ -18,7 +18,7 @@ where fn try_for_some_item(&mut self, mut f: F2) -> StreamResult where - E: Error, + E: Error + Send + Sync + 'static, F2: FnMut(Self::Item<'_>) -> Result<(), E>, { let map = &mut self.map; diff --git a/api/src/sparql.rs b/api/src/sparql.rs index a4d12916..03baec51 100644 --- a/api/src/sparql.rs +++ b/api/src/sparql.rs @@ -29,6 +29,7 @@ use crate::source::TripleSource; use crate::term::Term; + use std::borrow::Borrow; use std::error::Error; @@ -41,7 +42,7 @@ pub trait SparqlDataset { /// The type of triples that GRAPH and DESCRIBE queries will return. type TriplesResult: TripleSource; /// The type of errors that processing SPARQL queries may raise. - type SparqlError: Error + 'static; + type SparqlError: Error + Send + Sync + 'static; /// The type representing pre-processed queries. /// /// See [`prepare_query`](#tymethod.prepare_query) for more detail. @@ -81,7 +82,7 @@ pub trait SparqlDataset { /// [`prepare_query`](SparqlDataset::prepare_query) method. pub trait Query: Sized { /// The error type that might be raised when parsing a query. - type Error: Error + 'static; + type Error: Error + Send + Sync + 'static; /// Parse the given text into a [`Query`]. fn parse(query_source: &str) -> Result; } diff --git a/api/src/term.rs b/api/src/term.rs index 9348e15f..ba810f3c 100644 --- a/api/src/term.rs +++ b/api/src/term.rs @@ -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: std::error::Error + Send + Sync + 'static; /// Try to copy `term` into an instance of this type. fn try_from_term(term: T) -> Result; } diff --git a/api/src/term/_simple.rs b/api/src/term/_simple.rs index aa555bab..eae7034d 100644 --- a/api/src/term/_simple.rs +++ b/api/src/term/_simple.rs @@ -102,7 +102,7 @@ fn ensure_owned(m: MownStr) -> MownStr<'static> { let m = m.clone(); // Safety: the transmute bellow is safe, because if m.is_owned() is true, // then it's data is not restricted to lifetime 'a. - unsafe { std::mem::transmute(m) } + unsafe { std::mem::transmute::, mownstr::MownStr<'_>>(m) } } else { m.to_string().into() } diff --git a/c14n/src/lib.rs b/c14n/src/lib.rs index acef4c25..31da7d47 100644 --- a/c14n/src/lib.rs +++ b/c14n/src/lib.rs @@ -26,7 +26,7 @@ use thiserror::Error; /// Canonicalization error. #[derive(Debug, Error)] -pub enum C14nError { +pub enum C14nError { /// The dataset raised an error during canonicalization #[error("Error from dataset: {0}")] Dataset(#[from] E), diff --git a/c14n/src/rdfc10.rs b/c14n/src/rdfc10.rs index 2195608b..b7e42bf7 100644 --- a/c14n/src/rdfc10.rs +++ b/c14n/src/rdfc10.rs @@ -302,7 +302,7 @@ impl<'a, H: HashFunction, T: Term> C14nState<'a, H, T> { } /// Implements https://www.w3.org/TR/rdf-canon/#hash-nd-quads - fn hash_n_degree_quads( + fn hash_n_degree_quads( &self, identifier: &str, issuer: &BnodeIssuer, @@ -337,7 +337,7 @@ impl<'a, H: HashFunction, T: Term> C14nState<'a, H, T> { // Step 5 let mut ret_issuer: Option = None; for (related_hash, mut blank_node) in hn.into_iter() { - data_to_hash.update(&hex(&related_hash)); + data_to_hash.update(hex(&related_hash)); let mut chosen_path = String::new(); let mut chosen_issuer: Option = None; // Step 5.4 diff --git a/inmem/src/index.rs b/inmem/src/index.rs index 6177e558..c4092864 100644 --- a/inmem/src/index.rs +++ b/inmem/src/index.rs @@ -1,5 +1,6 @@ //! A [`TermIndex`] is a bidirectional assocuation of [terms](Term) with short numeric [indices](Index). use sophia_api::term::{FromTerm, GraphName, SimpleTerm, Term}; + use std::collections::hash_map::Entry; use std::collections::HashMap; use std::error::Error; @@ -64,7 +65,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 + Send + Sync + 'static; /// Get the index corresponding to term `t`, if it exists. /// diff --git a/isomorphism/src/test.rs b/isomorphism/src/test.rs index 8be3622c..bec78767 100644 --- a/isomorphism/src/test.rs +++ b/isomorphism/src/test.rs @@ -1,8 +1,9 @@ +use std::error::Error; + use super::*; use sophia_api::ns::xsd; use sophia_api::term::{assert_consistent_term_impl, BnodeId, IriRef, Term, TermKind}; use sophia_api::MownStr; -use std::error::Error; const FOAF_KNOWS: MyTerm = MyTerm::Iri("http://xmlns.com/foaf/0.1/knows"); const FOAF_MBOX: MyTerm = MyTerm::Iri("http://xmlns.com/foaf/0.1/mbox"); diff --git a/jsonld/src/parser/source.rs b/jsonld/src/parser/source.rs index 65908ee9..1445a965 100644 --- a/jsonld/src/parser/source.rs +++ b/jsonld/src/parser/source.rs @@ -33,7 +33,7 @@ impl Source for JsonLdQuadSource { fn try_for_some_item(&mut self, mut f: F) -> StreamResult where - E: std::error::Error, + E: std::error::Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), E>, { match self { diff --git a/resource/src/loader/_error.rs b/resource/src/loader/_error.rs index 7368f477..f33febd0 100644 --- a/resource/src/loader/_error.rs +++ b/resource/src/loader/_error.rs @@ -20,7 +20,7 @@ pub enum LoaderError { CantGuessSyntax(IriBuf), /// An error was encountered while parsing the data into an RDF graph #[error("Can not parse {0:?}: {1}")] - ParseError(IriBuf, Box), + ParseError(IriBuf, Box), } impl LoaderError { diff --git a/resource/src/resource/_error.rs b/resource/src/resource/_error.rs index 5c8be7eb..681bc3a1 100644 --- a/resource/src/resource/_error.rs +++ b/resource/src/resource/_error.rs @@ -5,7 +5,7 @@ use std::fmt; /// An error raised when creating a [`Resource`](crate::Resource) #[derive(Debug)] -pub enum ResourceError { +pub enum ResourceError { /// The IRI is not absolute (an can therefore not be dereferenced) IriNotAbsolute(IriRef>), /// The resource could not be loaded @@ -70,7 +70,10 @@ pub enum ResourceError { }, } -impl ResourceError { +impl ResourceError +where + E: Error + Send + Sync + 'static, +{ /// The identifier of the resource raising the error. /// /// NB: for errors raised during creation ([`ResourceError::IriNotAbsolute`], [`ResourceError::LoaderError`]), @@ -91,19 +94,25 @@ impl ResourceError { } } -impl fmt::Display for ResourceError { +impl fmt::Display for ResourceError +where + E: Error + Send + Sync + 'static, +{ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self) } } -impl From for ResourceError { +impl From for ResourceError +where + E: Error + Send + Sync + 'static, +{ fn from(value: crate::loader::LoaderError) -> Self { Self::LoaderError(value) } } -impl Error for ResourceError {} +impl Error for ResourceError where E: Error + Send + Sync + 'static {} /// A result whose error is a [`ResourceError`] pub type ResourceResult = Result::Error>>; diff --git a/rio/src/parser.rs b/rio/src/parser.rs index fb2edb90..7c23ccf4 100644 --- a/rio/src/parser.rs +++ b/rio/src/parser.rs @@ -6,9 +6,10 @@ //! published versions of Rio will always depend on the previously published version of Sophia, //! which makes it impossible for Sophia itself to rely on that feature. +use std::error::Error; + use crate::model::Trusted; use sophia_api::source::{StreamError, StreamError::*, StreamResult}; -use std::error::Error; /// Wrap a Rio [`TriplesParser`](rio_api::parser::TriplesParser) /// into a Sophia [`TripleSource`](sophia_api::source::TripleSource). @@ -17,7 +18,7 @@ pub struct StrictRioTripleSource(pub T); impl sophia_api::source::Source for StrictRioTripleSource where T: rio_api::parser::TriplesParser, - T::Error: Error + 'static, + T::Error: Error + Send + Sync + 'static, { type Item<'x> = Trusted>; @@ -25,7 +26,7 @@ where fn try_for_some_item(&mut self, mut f: F) -> StreamResult where - EF: Error, + EF: Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), EF>, { let parser = &mut self.0; @@ -50,7 +51,7 @@ pub struct StrictRioQuadSource(pub T); impl sophia_api::source::Source for StrictRioQuadSource where T: rio_api::parser::QuadsParser, - T::Error: Error + 'static, + T::Error: Error + Send + Sync + 'static, { type Item<'x> = Trusted>; @@ -58,7 +59,7 @@ where fn try_for_some_item(&mut self, mut f: F) -> StreamResult where - EF: Error, + EF: Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), EF>, { let parser = &mut self.0; @@ -83,7 +84,7 @@ pub struct GeneralizedRioSource(pub T); impl sophia_api::source::Source for GeneralizedRioSource where T: rio_api::parser::GeneralizedQuadsParser, - T::Error: Error + 'static, + T::Error: Error + Send + Sync + 'static, { type Item<'x> = Trusted>; @@ -91,7 +92,7 @@ where fn try_for_some_item(&mut self, mut f: F) -> StreamResult where - EF: Error, + EF: Error + Send + Sync + 'static, F: FnMut(Self::Item<'_>) -> Result<(), EF>, { let parser = &mut self.0; @@ -125,8 +126,8 @@ enum RioStreamError { } impl From for RioStreamError where - E1: Error, - E2: Error, + E1: Error + Send + Sync + 'static, + E2: Error + Send + Sync + 'static, { fn from(other: E1) -> Self { RioStreamError::Source(other) @@ -134,8 +135,8 @@ where } impl From> for StreamError where - E1: Error, - E2: Error, + E1: Error + Send + Sync + 'static, + E2: Error + Send + Sync + 'static, { fn from(other: RioStreamError) -> Self { match other { diff --git a/rio/src/serializer.rs b/rio/src/serializer.rs index fb4b565d..e4b41f1b 100644 --- a/rio/src/serializer.rs +++ b/rio/src/serializer.rs @@ -21,6 +21,7 @@ pub fn rio_format_triples( ) -> StreamResult<(), TS::Error, TF::Error> where TF: TriplesFormatter, + TF::Error: std::error::Error + Send + Sync + 'static, TS: TripleSource, { triples.try_for_each_triple(|t| { @@ -41,6 +42,7 @@ pub fn rio_format_quads( ) -> StreamResult<(), QS::Error, QF::Error> where QF: QuadsFormatter, + QF::Error: std::error::Error + Send + Sync + 'static, QS: QuadSource, { quads.try_for_each_quad(|q| { diff --git a/turtle/src/serializer/_pretty.rs b/turtle/src/serializer/_pretty.rs index b6ffe41a..62c34570 100644 --- a/turtle/src/serializer/_pretty.rs +++ b/turtle/src/serializer/_pretty.rs @@ -2,13 +2,13 @@ //! //! Possible improvements: //! 1. PrettifiableDataset should encapsulate some of the "indexes" built by Prettifier -//! (labelled, subject_types, named_graphs) -//! and build directly in CollectibleDataset::from_quad_source(). +//! (labelled, subject_types, named_graphs) +//! and build directly in CollectibleDataset::from_quad_source(). //! //! 2. Instead of writing directly to the output, -//! generate a hierarchical structure, -//! and decide on line breaks and indentation based on the overall structure, -//! rather than a priori. +//! generate a hierarchical structure, +//! and decide on line breaks and indentation based on the overall structure, +//! rather than a priori. use super::turtle::TurtleConfig; use regex::Regex; diff --git a/turtle/src/serializer/trig.rs b/turtle/src/serializer/trig.rs index 921efd28..2219f545 100644 --- a/turtle/src/serializer/trig.rs +++ b/turtle/src/serializer/trig.rs @@ -107,11 +107,13 @@ impl Stringifier for TrigSerializer> { #[cfg(test)] pub(crate) mod test { + use std::error::Error; + use super::*; use sophia_api::term::SimpleTerm; + use sophia_api::{dataset::Dataset, quad::Spog}; use sophia_isomorphism::isomorphic_datasets; - use std::error::Error; const TESTS: &[&str] = &[ "#empty trig", @@ -177,7 +179,7 @@ pub(crate) mod test { ]; #[test] - fn roundtrip_not_pretty() -> Result<(), Box> { + fn roundtrip_not_pretty() -> Result<(), Box> { for ttl in TESTS { println!("==========\n{}\n----------", ttl); let g1: Vec> = crate::parser::trig::parse_str(ttl).collect_quads()?; diff --git a/turtle/src/serializer/turtle.rs b/turtle/src/serializer/turtle.rs index cf944268..514aa58b 100644 --- a/turtle/src/serializer/turtle.rs +++ b/turtle/src/serializer/turtle.rs @@ -209,10 +209,11 @@ impl Stringifier for TurtleSerializer> { #[cfg(test)] pub(crate) mod test { + use std::error::Error; + use super::*; use sophia_api::graph::Graph; use sophia_isomorphism::isomorphic_graphs; - use std::error::Error; const TESTS: &[&str] = &[ "#empty ttl", @@ -246,7 +247,7 @@ pub(crate) mod test { ]; #[test] - fn roundtrip_not_pretty() -> Result<(), Box> { + fn roundtrip_not_pretty() -> Result<(), Box> { for ttl in TESTS { println!("==========\n{}\n----------", ttl); let g1: Vec<[SimpleTerm; 3]> =