From 6fbf401fb527a85b5b1150b45c1a7960221a02bd Mon Sep 17 00:00:00 2001 From: Mikhail Katychev Date: Tue, 23 Jul 2024 20:00:41 -0500 Subject: [PATCH 1/3] resource is send + sync --- resource/src/resource/_error.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resource/src/resource/_error.rs b/resource/src/resource/_error.rs index 5c8be7eb..13b6628f 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,7 @@ pub enum ResourceError { }, } -impl ResourceError { +impl ResourceError { /// The identifier of the resource raising the error. /// /// NB: for errors raised during creation ([`ResourceError::IriNotAbsolute`], [`ResourceError::LoaderError`]), @@ -91,19 +91,19 @@ impl ResourceError { } } -impl fmt::Display for ResourceError { +impl fmt::Display for ResourceError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self) } } -impl From for ResourceError { +impl From for ResourceError { fn from(value: crate::loader::LoaderError) -> Self { Self::LoaderError(value) } } -impl Error for ResourceError {} +impl Error for ResourceError {} /// A result whose error is a [`ResourceError`] pub type ResourceResult = Result::Error>>; From 2ff36c9b7cf4ec2991ee4132dba1961ed7c392d8 Mon Sep 17 00:00:00 2001 From: Mikhail Katychev Date: Tue, 23 Jul 2024 20:17:39 -0500 Subject: [PATCH 2/3] added threadsafe contracints to resource error --- resource/src/lib.rs | 2 +- resource/src/loader/_error.rs | 2 +- resource/src/resource/_error.rs | 7 +++++-- resource/src/resource/_struct.rs | 1 + resource/src/resource/test.rs | 4 +++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/resource/src/lib.rs b/resource/src/lib.rs index 508961d5..3aff4c93 100644 --- a/resource/src/lib.rs +++ b/resource/src/lib.rs @@ -72,7 +72,7 @@ mod test { pub const F5_LEN: usize = 20; pub type MyGraph = Vec<[SimpleTerm<'static>; 3]>; - pub type TestResult = Result<(), Box>; + pub type TestResult = Result<(), Box>; pub fn make_loader() -> LocalLoader { let ns = NS.map_unchecked(MownStr::from); 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 13b6628f..125786d5 100644 --- a/resource/src/resource/_error.rs +++ b/resource/src/resource/_error.rs @@ -70,7 +70,10 @@ pub enum ResourceError { }, } -impl ResourceError { +impl ResourceError +where + Self: Send + Sync + 'static, +{ /// The identifier of the resource raising the error. /// /// NB: for errors raised during creation ([`ResourceError::IriNotAbsolute`], [`ResourceError::LoaderError`]), @@ -103,7 +106,7 @@ impl From for Reso } } -impl Error for ResourceError {} +impl Error for ResourceError where Self: Send + Sync + 'static {} /// A result whose error is a [`ResourceError`] pub type ResourceResult = Result::Error>>; diff --git a/resource/src/resource/_struct.rs b/resource/src/resource/_struct.rs index 5860800f..fd2062ca 100644 --- a/resource/src/resource/_struct.rs +++ b/resource/src/resource/_struct.rs @@ -22,6 +22,7 @@ pub struct Resource { impl Resource where G: Graph + 'static, + G::Error: Send + Sync + 'static, L: Loader, { /// Constructor diff --git a/resource/src/resource/test.rs b/resource/src/resource/test.rs index 56948db5..467744ad 100644 --- a/resource/src/resource/test.rs +++ b/resource/src/resource/test.rs @@ -597,6 +597,8 @@ fn no_reload() -> TestResult { Ok(()) } -fn make_rsc(iri: Iri<&str>) -> Result, Box> { +fn make_rsc( + iri: Iri<&str>, +) -> Result, Box> { Ok(make_loader().arced().get_resource(iri)?) } From 6456ab6ed31dfcca6ced499765a0ec06eee500de Mon Sep 17 00:00:00 2001 From: Mikhail Katychev Date: Wed, 24 Jul 2024 16:14:01 -0500 Subject: [PATCH 3/3] handle xsd::decimal --- api/src/term/_native_literal.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/term/_native_literal.rs b/api/src/term/_native_literal.rs index 4410c178..1b301cee 100644 --- a/api/src/term/_native_literal.rs +++ b/api/src/term/_native_literal.rs @@ -235,6 +235,7 @@ impl TryFromTerm for f64 { if let Some(lex) = term.lexical_form() { if Term::eq(&term.datatype().unwrap(), xsd::double) || Term::eq(&term.datatype().unwrap(), xsd::float) + || Term::eq(&term.datatype().unwrap(), xsd::decimal) { lex.parse() } else {