Removes NamedNode::from_str

pull/10/head
Tpt 5 years ago
parent 21ad76c7cf
commit a803daa64b
  1. 2
      lib/src/lib.rs
  2. 2
      lib/src/model/graph.rs
  3. 13
      lib/src/model/named_node.rs
  4. 127
      lib/src/model/vocab.rs
  5. 6
      lib/src/repository.rs
  6. 3
      lib/src/rio.rs
  7. 14
      lib/src/sparql/xml_results.rs
  8. 2
      lib/src/store/memory.rs
  9. 8
      lib/src/store/numeric_encoder.rs
  10. 2
      lib/src/store/rocksdb.rs
  11. 16
      lib/tests/rdf_test_cases.rs
  12. 133
      lib/tests/sparql_test_cases.rs

@ -19,7 +19,7 @@
//! let connection = repository.connection().unwrap(); //! let connection = repository.connection().unwrap();
//! //!
//! // insertion //! // insertion
//! let ex = NamedNode::from_str("http://example.com").unwrap(); //! let ex = NamedNode::new("http://example.com");
//! let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None); //! let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None);
//! connection.insert(&quad); //! connection.insert(&quad);
//! //!

@ -15,7 +15,7 @@ use std::iter::FromIterator;
/// use std::str::FromStr; /// use std::str::FromStr;
/// ///
/// let mut graph = SimpleGraph::default(); /// let mut graph = SimpleGraph::default();
/// let ex = NamedNode::from_str("http://example.com").unwrap(); /// let ex = NamedNode::new("http://example.com");
/// let triple = Triple::new(ex.clone(), ex.clone(), ex.clone()); /// let triple = Triple::new(ex.clone(), ex.clone(), ex.clone());
/// graph.insert(triple.clone()); /// graph.insert(triple.clone());
/// let results: Vec<Triple> = graph.triples_for_subject(&ex.into()).cloned().collect(); /// let results: Vec<Triple> = graph.triples_for_subject(&ex.into()).cloned().collect();

@ -1,8 +1,5 @@
use crate::Error;
use crate::Result;
use rio_api::model as rio; use rio_api::model as rio;
use std::fmt; use std::fmt;
use std::str::FromStr;
/// A RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) /// A RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri)
/// ///
@ -16,7 +13,7 @@ use std::str::FromStr;
/// ///
/// assert_eq!( /// assert_eq!(
/// "<http://example.com/foo>", /// "<http://example.com/foo>",
/// NamedNode::from_str("http://example.com/foo").unwrap().to_string() /// NamedNode::new("http://example.com/foo").to_string()
/// ) /// )
/// ``` /// ```
/// ///
@ -48,11 +45,3 @@ impl NamedNode {
self.iri self.iri
} }
} }
impl FromStr for NamedNode {
type Err = Error;
fn from_str(s: &str) -> Result<Self> {
Ok(Self::new(s))
}
}

@ -4,59 +4,58 @@ pub mod rdf {
//! [RDF 1.1](https://www.w3.org/TR/rdf11-concepts/) vocabulary //! [RDF 1.1](https://www.w3.org/TR/rdf11-concepts/) vocabulary
use crate::model::named_node::NamedNode; use crate::model::named_node::NamedNode;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use std::str::FromStr;
lazy_static! { lazy_static! {
/// The class of containers of alternatives. /// The class of containers of alternatives.
pub static ref ALT: NamedNode = pub static ref ALT: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt");
/// The class of unordered containers. /// The class of unordered containers.
pub static ref BAG: NamedNode = pub static ref BAG: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag");
/// The first item in the subject RDF list. /// The first item in the subject RDF list.
pub static ref FIRST: NamedNode = pub static ref FIRST: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#first").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#first");
/// The class of HTML literal values. /// The class of HTML literal values.
pub static ref HTML: NamedNode = pub static ref HTML: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML");
/// The class of language-tagged string literal values. /// The class of language-tagged string literal values.
pub static ref LANG_STRING: NamedNode = pub static ref LANG_STRING: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");
/// The class of RDF Lists. /// The class of RDF Lists.
pub static ref LIST: NamedNode = pub static ref LIST: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#List").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#List");
pub static ref NIL: NamedNode = pub static ref NIL: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil");
/// The object of the subject RDF statement. /// The object of the subject RDF statement.
pub static ref OBJECT: NamedNode = pub static ref OBJECT: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#object").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#object");
/// The predicate of the subject RDF statement. /// The predicate of the subject RDF statement.
pub static ref PREDICATE: NamedNode = pub static ref PREDICATE: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate");
/// The class of RDF properties. /// The class of RDF properties.
pub static ref PROPERTY: NamedNode = pub static ref PROPERTY: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#Property").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#Property");
/// The rest of the subject RDF list after the first item. /// The rest of the subject RDF list after the first item.
pub static ref REST: NamedNode = pub static ref REST: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest");
/// The class of ordered containers. /// The class of ordered containers.
pub static ref SEQ: NamedNode = pub static ref SEQ: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq");
/// The class of RDF statements. /// The class of RDF statements.
pub static ref STATEMENT: NamedNode = pub static ref STATEMENT: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement");
/// The subject of the subject RDF statement. /// The subject of the subject RDF statement.
pub static ref SUBJECT: NamedNode = pub static ref SUBJECT: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject");
/// The subject is an instance of a class. /// The subject is an instance of a class.
pub static ref TYPE: NamedNode = pub static ref TYPE: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#type").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
/// Idiomatic property used for structured values. /// Idiomatic property used for structured values.
pub static ref VALUE: NamedNode = pub static ref VALUE: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#value").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#value");
/// The class of XML literal values. /// The class of XML literal values.
pub static ref XML_LITERAL: NamedNode = pub static ref XML_LITERAL: NamedNode =
NamedNode::from_str("http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral").unwrap(); NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral");
} }
} }
@ -64,54 +63,53 @@ pub mod rdfs {
//! [RDFS](https://www.w3.org/TR/rdf-schema/) vocabulary //! [RDFS](https://www.w3.org/TR/rdf-schema/) vocabulary
use crate::model::named_node::NamedNode; use crate::model::named_node::NamedNode;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use std::str::FromStr;
lazy_static! { lazy_static! {
/// The class of classes. /// The class of classes.
pub static ref CLASS: NamedNode = pub static ref CLASS: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#Class").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#Class");
/// A description of the subject resource. /// A description of the subject resource.
pub static ref COMMENT: NamedNode = pub static ref COMMENT: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#comment").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#comment");
/// The class of RDF containers. /// The class of RDF containers.
pub static ref CONTAINER: NamedNode = pub static ref CONTAINER: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#Container").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#Container");
/// The class of container membership properties, rdf:_1, rdf:_2, ..., all of which are sub-properties of 'member'. /// The class of container membership properties, rdf:_1, rdf:_2, ..., all of which are sub-properties of 'member'.
pub static ref CONTAINER_MEMBERSHIP_PROPERTY: NamedNode = pub static ref CONTAINER_MEMBERSHIP_PROPERTY: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#ContainerMembershipProperty").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#ContainerMembershipProperty");
/// The class of RDF datatypes. /// The class of RDF datatypes.
pub static ref DATATYPE: NamedNode = pub static ref DATATYPE: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#Datatype").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#Datatype");
/// A domain of the subject property. /// A domain of the subject property.
pub static ref DOMAIN: NamedNode = pub static ref DOMAIN: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#domain").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#domain");
/// The definition of the subject resource. /// The definition of the subject resource.
pub static ref IS_DEFINED_BY: NamedNode = pub static ref IS_DEFINED_BY: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#isDefinedBy").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#isDefinedBy");
/// A human-readable name for the subject. /// A human-readable name for the subject.
pub static ref LABEL: NamedNode = pub static ref LABEL: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#label").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#label");
/// The class of literal values, e.g. textual strings and integers. /// The class of literal values, e.g. textual strings and integers.
pub static ref LITERAL: NamedNode = pub static ref LITERAL: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#Literal").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#Literal");
/// A member of the subject resource. /// A member of the subject resource.
pub static ref MEMBER: NamedNode = pub static ref MEMBER: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#member").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#member");
/// A range of the subject property. /// A range of the subject property.
pub static ref RANGE: NamedNode = pub static ref RANGE: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#range").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#range");
/// The class resource, everything. /// The class resource, everything.
pub static ref RESOURCE: NamedNode = pub static ref RESOURCE: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#Resource").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#Resource");
/// Further information about the subject resource. /// Further information about the subject resource.
pub static ref SEE_ALSO: NamedNode = pub static ref SEE_ALSO: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#seeAlso").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#seeAlso");
/// The subject is a subclass of a class. /// The subject is a subclass of a class.
pub static ref SUB_CLASS_OF: NamedNode = pub static ref SUB_CLASS_OF: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#subClassOf").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#subClassOf");
/// The subject is a subproperty of a property. /// The subject is a subproperty of a property.
pub static ref SUB_PROPERTY_OF: NamedNode = pub static ref SUB_PROPERTY_OF: NamedNode =
NamedNode::from_str("http://www.w3.org/2000/01/rdf-schema#subPropertyOf").unwrap(); NamedNode::new("http://www.w3.org/2000/01/rdf-schema#subPropertyOf");
} }
} }
@ -119,98 +117,97 @@ pub mod xsd {
//! `NamedNode`s for [RDF compatible XSD datatypes](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-compatible-xsd-types) //! `NamedNode`s for [RDF compatible XSD datatypes](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-compatible-xsd-types)
use crate::model::named_node::NamedNode; use crate::model::named_node::NamedNode;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use std::str::FromStr;
lazy_static! { lazy_static! {
/// true, false /// true, false
pub static ref BOOLEAN: NamedNode = pub static ref BOOLEAN: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#boolean").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#boolean");
/// 128…+127 (8 bit) /// 128…+127 (8 bit)
pub static ref BYTE: NamedNode = pub static ref BYTE: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#byte").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#byte");
/// Dates (yyyy-mm-dd) with or without timezone /// Dates (yyyy-mm-dd) with or without timezone
pub static ref DATE: NamedNode = pub static ref DATE: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#date").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#date");
/// Duration of time (days, hours, minutes, seconds only) /// Duration of time (days, hours, minutes, seconds only)
pub static ref DAY_TIME_DURATION: NamedNode = pub static ref DAY_TIME_DURATION: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#dayTimeDuration").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#dayTimeDuration");
/// Date and time with or without timezone /// Date and time with or without timezone
pub static ref DATE_TIME: NamedNode = pub static ref DATE_TIME: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#dateTime").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#dateTime");
/// Date and time with required timezone /// Date and time with required timezone
pub static ref DATE_TIME_STAMP: NamedNode = pub static ref DATE_TIME_STAMP: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#dateTimeStamp").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#dateTimeStamp");
/// Arbitrary-precision decimal numbers /// Arbitrary-precision decimal numbers
pub static ref DECIMAL: NamedNode = pub static ref DECIMAL: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#decimal").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#decimal");
/// 64-bit floating point numbers incl. ±Inf, ±0, NaN /// 64-bit floating point numbers incl. ±Inf, ±0, NaN
pub static ref DOUBLE: NamedNode = pub static ref DOUBLE: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#double").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#double");
/// Duration of time /// Duration of time
pub static ref DURATION: NamedNode = pub static ref DURATION: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#duration").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#duration");
/// 32-bit floating point numbers incl. ±Inf, ±0, NaN /// 32-bit floating point numbers incl. ±Inf, ±0, NaN
pub static ref FLOAT: NamedNode = pub static ref FLOAT: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#float").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#float");
/// Gregorian calendar day of the month /// Gregorian calendar day of the month
pub static ref G_DAY: NamedNode = pub static ref G_DAY: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#gDay").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#gDay");
/// Gregorian calendar month /// Gregorian calendar month
pub static ref G_MONTH: NamedNode = pub static ref G_MONTH: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#gMonth").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#gMonth");
/// Gregorian calendar month and day /// Gregorian calendar month and day
pub static ref G_MONTH_DAY: NamedNode = pub static ref G_MONTH_DAY: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#gMonthDay").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#gMonthDay");
/// Gregorian calendar year /// Gregorian calendar year
pub static ref G_YEAR: NamedNode = pub static ref G_YEAR: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#gYear").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#gYear");
/// Gregorian calendar year and month /// Gregorian calendar year and month
pub static ref G_YEAR_MONTH: NamedNode = pub static ref G_YEAR_MONTH: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#gYearMonth").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#gYearMonth");
/// -2147483648…+2147483647 (32 bit) /// -2147483648…+2147483647 (32 bit)
pub static ref INT: NamedNode = pub static ref INT: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#int").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#int");
/// Arbitrary-size integer numbers /// Arbitrary-size integer numbers
pub static ref INTEGER: NamedNode = pub static ref INTEGER: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#integer").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#integer");
/// -9223372036854775808…+9223372036854775807 (64 bit) /// -9223372036854775808…+9223372036854775807 (64 bit)
pub static ref LONG: NamedNode = pub static ref LONG: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#long").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#long");
/// Integer numbers <0 /// Integer numbers <0
pub static ref NEGATIVE_INTEGER: NamedNode = pub static ref NEGATIVE_INTEGER: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#negativeInteger").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#negativeInteger");
/// Integer numbers ≥0 /// Integer numbers ≥0
pub static ref NON_NEGATIVE_INTEGER: NamedNode = pub static ref NON_NEGATIVE_INTEGER: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#nonNegativeInteger").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#nonNegativeInteger");
/// Integer numbers ≤0 /// Integer numbers ≤0
pub static ref NON_POSITIVE_INTEGER: NamedNode = pub static ref NON_POSITIVE_INTEGER: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#nonPositiveInteger").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#nonPositiveInteger");
/// Integer numbers >0 /// Integer numbers >0
pub static ref POSITIVE_INTEGER: NamedNode = pub static ref POSITIVE_INTEGER: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#positiveInteger").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#positiveInteger");
/// Times (hh:mm:ss.sss…) with or without timezone /// Times (hh:mm:ss.sss…) with or without timezone
pub static ref TIME: NamedNode = pub static ref TIME: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#time").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#time");
/// -32768…+32767 (16 bit) /// -32768…+32767 (16 bit)
pub static ref SHORT: NamedNode = pub static ref SHORT: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#short").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#short");
/// Character strings (but not all Unicode character strings) /// Character strings (but not all Unicode character strings)
pub static ref STRING: NamedNode = pub static ref STRING: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#string").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#string");
/// 0…255 (8 bit) /// 0…255 (8 bit)
pub static ref UNSIGNED_BYTE: NamedNode = pub static ref UNSIGNED_BYTE: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#unsignedByte").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#unsignedByte");
/// 0…4294967295 (32 bit) /// 0…4294967295 (32 bit)
pub static ref UNSIGNED_INT: NamedNode = pub static ref UNSIGNED_INT: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#unsignedInt").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#unsignedInt");
/// 0…18446744073709551615 (64 bit) /// 0…18446744073709551615 (64 bit)
pub static ref UNSIGNED_LONG: NamedNode = pub static ref UNSIGNED_LONG: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#unsignedLong").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#unsignedLong");
/// 0…65535 (16 bit) /// 0…65535 (16 bit)
pub static ref UNSIGNED_SHORT: NamedNode = pub static ref UNSIGNED_SHORT: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#unsignedShort").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#unsignedShort");
/// Duration of time (months and years only) /// Duration of time (months and years only)
pub static ref YEAR_MONTH_DURATION: NamedNode = pub static ref YEAR_MONTH_DURATION: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/XMLSchema#yearMonthDuration").unwrap(); NamedNode::new("http://www.w3.org/2001/XMLSchema#yearMonthDuration");
} }
} }

@ -22,7 +22,7 @@ use std::io::Read;
/// let connection = repository.connection().unwrap(); /// let connection = repository.connection().unwrap();
/// ///
/// // insertion /// // insertion
/// let ex = NamedNode::from_str("http://example.com").unwrap(); /// let ex = NamedNode::new("http://example.com");
/// let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None); /// let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None);
/// connection.insert(&quad); /// connection.insert(&quad);
/// ///
@ -73,7 +73,7 @@ pub trait RepositoryConnection: Clone {
/// let connection = repository.connection().unwrap(); /// let connection = repository.connection().unwrap();
/// ///
/// // insertions /// // insertions
/// let ex = NamedNode::from_str("http://example.com").unwrap(); /// let ex = NamedNode::new("http://example.com");
/// connection.insert(&Quad::new(ex.clone(), ex.clone(), ex.clone(), None)); /// connection.insert(&Quad::new(ex.clone(), ex.clone(), ex.clone(), None));
/// ///
/// // SPARQL query /// // SPARQL query
@ -97,7 +97,7 @@ pub trait RepositoryConnection: Clone {
/// let connection = repository.connection().unwrap(); /// let connection = repository.connection().unwrap();
/// ///
/// // insertion /// // insertion
/// let ex = NamedNode::from_str("http://example.com").unwrap(); /// let ex = NamedNode::new("http://example.com");
/// let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None); /// let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None);
/// connection.insert(&quad); /// connection.insert(&quad);
/// ///

@ -8,7 +8,6 @@ use rio_turtle::{NTriplesParser, TurtleParser};
use rio_xml::RdfXmlParser; use rio_xml::RdfXmlParser;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io::BufRead; use std::io::BufRead;
use std::str::FromStr;
/// Reads a [N-Triples](https://www.w3.org/TR/n-triples/) file from a Rust `BufRead` and returns an iterator of the read `Triple`s /// Reads a [N-Triples](https://www.w3.org/TR/n-triples/) file from a Rust `BufRead` and returns an iterator of the read `Triple`s
pub fn read_ntriples<R: BufRead>(reader: R) -> Result<impl Iterator<Item = Result<Triple>>> { pub fn read_ntriples<R: BufRead>(reader: R) -> Result<impl Iterator<Item = Result<Triple>>> {
@ -68,7 +67,7 @@ fn convert_named_or_blank_node(
} }
fn convert_named_node(value: rio::NamedNode) -> Result<NamedNode> { fn convert_named_node(value: rio::NamedNode) -> Result<NamedNode> {
NamedNode::from_str(value.iri) Ok(NamedNode::new(value.iri))
} }
fn convert_blank_node( fn convert_blank_node(

@ -17,7 +17,6 @@ use std::collections::BTreeMap;
use std::io::BufRead; use std::io::BufRead;
use std::io::Write; use std::io::Write;
use std::iter::empty; use std::iter::empty;
use std::str::FromStr;
pub fn write_xml_results<W: Write>(results: QueryResult<'_>, sink: W) -> Result<W> { pub fn write_xml_results<W: Write>(results: QueryResult<'_>, sink: W) -> Result<W> {
let mut writer = Writer::new(sink); let mut writer = Writer::new(sink);
@ -345,11 +344,9 @@ impl<R: BufRead> Iterator for ResultsIterator<R> {
} else if attr.key == b"datatype" { } else if attr.key == b"datatype" {
match attr.unescaped_value() { match attr.unescaped_value() {
Ok(val) => { Ok(val) => {
match NamedNode::from_str(&self.reader.decode(&val)) datatype = Some(NamedNode::new(
{ self.reader.decode(&val).to_string(),
Ok(dt) => datatype = Some(dt), ));
Err(error) => return Some(Err(error)),
}
} }
Err(error) => return Some(Err(error.into())), Err(error) => return Some(Err(error.into())),
} }
@ -368,10 +365,7 @@ impl<R: BufRead> Iterator for ResultsIterator<R> {
}, },
Event::Text(event) => match event.unescaped() { Event::Text(event) => match event.unescaped() {
Ok(data) => match state { Ok(data) => match state {
State::Uri => match NamedNode::from_str(&self.reader.decode(&data)) { State::Uri => term = Some(NamedNode::new(self.reader.decode(&data)).into()),
Ok(named_node) => term = Some(named_node.into()),
Err(error) => return Some(Err(error)),
},
State::BNode => { State::BNode => {
term = Some( term = Some(
self.bnodes_map self.bnodes_map

@ -25,7 +25,7 @@ use std::sync::RwLockWriteGuard;
/// let connection = repository.connection().unwrap(); /// let connection = repository.connection().unwrap();
/// ///
/// // insertion /// // insertion
/// let ex = NamedNode::from_str("http://example.com").unwrap(); /// let ex = NamedNode::new("http://example.com");
/// let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None); /// let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None);
/// connection.insert(&quad); /// connection.insert(&quad);
/// ///

@ -795,13 +795,11 @@ impl<T> From<PoisonError<T>> for MutexPoisonError {
#[test] #[test]
fn test_encoding() { fn test_encoding() {
use std::str::FromStr;
let encoder: Encoder<MemoryStringStore> = Encoder::default(); let encoder: Encoder<MemoryStringStore> = Encoder::default();
let terms: Vec<Term> = vec![ let terms: Vec<Term> = vec![
NamedNode::from_str("http://foo.com").unwrap().into(), NamedNode::new("http://foo.com").into(),
NamedNode::from_str("http://bar.com").unwrap().into(), NamedNode::new("http://bar.com").into(),
NamedNode::from_str("http://foo.com").unwrap().into(), NamedNode::new("http://foo.com").into(),
BlankNode::default().into(), BlankNode::default().into(),
Literal::new_simple_literal("foo").into(), Literal::new_simple_literal("foo").into(),
Literal::from(true).into(), Literal::from(true).into(),

@ -35,7 +35,7 @@ use std::sync::Mutex;
/// let connection = repository.connection().unwrap(); /// let connection = repository.connection().unwrap();
/// ///
/// // insertion /// // insertion
/// let ex = NamedNode::from_str("http://example.com").unwrap(); /// let ex = NamedNode::new("http://example.com");
/// let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None); /// let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None);
/// connection.insert(&quad); /// connection.insert(&quad);
/// ///

@ -200,24 +200,18 @@ impl TestManifest {
pub mod mf { pub mod mf {
use lazy_static::lazy_static; use lazy_static::lazy_static;
use rudf::model::NamedNode; use rudf::model::NamedNode;
use std::str::FromStr;
lazy_static! { lazy_static! {
pub static ref INCLUDE: NamedNode = pub static ref INCLUDE: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include");
.unwrap();
pub static ref ENTRIES: NamedNode = pub static ref ENTRIES: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#entries") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#entries");
.unwrap();
pub static ref NAME: NamedNode = pub static ref NAME: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#name") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#name");
.unwrap();
pub static ref ACTION: NamedNode = pub static ref ACTION: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action");
.unwrap();
pub static ref RESULT: NamedNode = pub static ref RESULT: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result");
.unwrap();
} }
} }

@ -15,7 +15,6 @@ use std::fmt;
use std::fs::File; use std::fs::File;
use std::io::{BufRead, BufReader}; use std::io::{BufRead, BufReader};
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr;
#[test] #[test]
fn sparql_w3c_syntax_testsuite() { fn sparql_w3c_syntax_testsuite() {
@ -23,11 +22,11 @@ fn sparql_w3c_syntax_testsuite() {
let manifest_11_url = let manifest_11_url =
"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest.ttl"; "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest.ttl";
let test_blacklist = vec![ let test_blacklist = vec![
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql2/manifest#syntax-form-construct02").unwrap(), NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql2/manifest#syntax-form-construct02"),
//TODO: Deserialization of the serialization failing: //TODO: Deserialization of the serialization failing:
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql2/manifest#syntax-form-construct04").unwrap(), NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql2/manifest#syntax-form-construct04"),
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql2/manifest#syntax-function-04").unwrap(), NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql2/manifest#syntax-function-04"),
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#syntax-qname-04").unwrap(), NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#syntax-qname-04"),
]; ];
for test_result in TestManifest::new(manifest_10_url).chain(TestManifest::new(manifest_11_url)) for test_result in TestManifest::new(manifest_10_url).chain(TestManifest::new(manifest_11_url))
@ -90,63 +89,29 @@ fn sparql_w3c_query_evaluation_testsuite() {
]; ];
let test_blacklist = vec![ let test_blacklist = vec![
//Multiple writing of the same xsd:integer. Our system does strong normalization. //Multiple writing of the same xsd:integer. Our system does strong normalization.
NamedNode::from_str( NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-1"),
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-1", NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-9"),
).unwrap(), NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-str-1"),
NamedNode::from_str( NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-str-2"),
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-9", NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-equals/manifest#eq-graph-1"),
).unwrap(), NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-equals/manifest#eq-graph-2"),
NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-str-1",
).unwrap(),
NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-str-2",
).unwrap(),
NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-equals/manifest#eq-graph-1",
).unwrap(),
NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-equals/manifest#eq-graph-2",
).unwrap(),
//Multiple writing of the same xsd:double. Our system does strong normalization. //Multiple writing of the same xsd:double. Our system does strong normalization.
NamedNode::from_str( NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm"),
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm", NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-simple"),
).unwrap(), NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-eq"),
NamedNode::from_str( NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-not-eq"),
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-simple",
).unwrap(),
NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-eq",
).unwrap(),
NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#sameTerm-not-eq",
).unwrap(),
//Simple literal vs xsd:string. We apply RDF 1.1 //Simple literal vs xsd:string. We apply RDF 1.1
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-2").unwrap(), NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-2"),
//URI normalization: we are not normalizing well //URI normalization: we are not normalizing well
NamedNode::from_str( NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#normalization-1"),
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#normalization-1", NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#normalization-2"),
).unwrap(), NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#normalization-3"),
NamedNode::from_str( NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#kanji-1"),
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#normalization-2", NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#kanji-2"),
).unwrap(),
NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#normalization-3",
).unwrap(),
NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#kanji-1",
).unwrap(),
NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/i18n/manifest#kanji-2",
).unwrap(),
//Test on curly brace scoping with OPTIONAL filter //Test on curly brace scoping with OPTIONAL filter
NamedNode::from_str( NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional-filter/manifest#dawg-optional-filter-005-not-simplified"),
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional-filter/manifest#dawg-optional-filter-005-not-simplified",
).unwrap(),
//DATATYPE("foo"@en) returns rdf:langString in SPARQL 1.1 //DATATYPE("foo"@en) returns rdf:langString in SPARQL 1.1
NamedNode::from_str( NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-datatype-2")
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-datatype-2",
).unwrap()
]; ];
for test_result in manifest_10_urls for test_result in manifest_10_urls
@ -284,34 +249,24 @@ fn read_file(url: &str) -> Result<impl BufRead> {
mod rs { mod rs {
use lazy_static::lazy_static; use lazy_static::lazy_static;
use rudf::model::NamedNode; use rudf::model::NamedNode;
use std::str::FromStr;
lazy_static! { lazy_static! {
pub static ref RESULT_SET: NamedNode = pub static ref RESULT_SET: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/result-set#ResultSet") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/result-set#ResultSet");
.unwrap(); pub static ref RESULT_VARIABLE: NamedNode =
pub static ref RESULT_VARIABLE: NamedNode = NamedNode::from_str( NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/result-set#resultVariable");
"http://www.w3.org/2001/sw/DataAccess/tests/result-set#resultVariable"
)
.unwrap();
pub static ref SOLUTION: NamedNode = pub static ref SOLUTION: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/result-set#solution") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/result-set#solution");
.unwrap();
pub static ref BINDING: NamedNode = pub static ref BINDING: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/result-set#binding") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/result-set#binding");
.unwrap();
pub static ref VALUE: NamedNode = pub static ref VALUE: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/result-set#value") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/result-set#value");
.unwrap();
pub static ref VARIABLE: NamedNode = pub static ref VARIABLE: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/result-set#variable") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/result-set#variable");
.unwrap();
pub static ref INDEX: NamedNode = pub static ref INDEX: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/result-set#index") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/result-set#index");
.unwrap();
pub static ref BOOLEAN: NamedNode = pub static ref BOOLEAN: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/result-set#boolean") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/result-set#boolean");
.unwrap();
} }
} }
@ -443,42 +398,32 @@ impl TestManifest {
pub mod mf { pub mod mf {
use lazy_static::lazy_static; use lazy_static::lazy_static;
use rudf::model::NamedNode; use rudf::model::NamedNode;
use std::str::FromStr;
lazy_static! { lazy_static! {
pub static ref INCLUDE: NamedNode = pub static ref INCLUDE: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include");
.unwrap();
pub static ref ENTRIES: NamedNode = pub static ref ENTRIES: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#entries") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#entries");
.unwrap();
pub static ref NAME: NamedNode = pub static ref NAME: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#name") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#name");
.unwrap();
pub static ref ACTION: NamedNode = pub static ref ACTION: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action");
.unwrap();
pub static ref RESULT: NamedNode = pub static ref RESULT: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result");
.unwrap();
} }
} }
pub mod qt { pub mod qt {
use lazy_static::lazy_static; use lazy_static::lazy_static;
use rudf::model::NamedNode; use rudf::model::NamedNode;
use std::str::FromStr;
lazy_static! { lazy_static! {
pub static ref QUERY: NamedNode = pub static ref QUERY: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-query#query") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-query#query");
.unwrap();
pub static ref DATA: NamedNode = pub static ref DATA: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-query#data") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-query#data");
.unwrap();
pub static ref GRAPH_DATA: NamedNode = pub static ref GRAPH_DATA: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-query#graphData") NamedNode::new("http://www.w3.org/2001/sw/DataAccess/tests/test-query#graphData");
.unwrap();
} }
} }

Loading…
Cancel
Save