diff --git a/cli/src/main.rs b/cli/src/main.rs index b0f7a6fa..9e9a0dbd 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -2354,7 +2354,7 @@ mod tests { .build(); ServerTest::new()?.test_body( request, - "{\"head\":{\"vars\":[\"s\",\"p\",\"o\"]},\"results\":{\"bindings\":[]}}", + r#"{"head":{"vars":["s","p","o"]},"results":{"bindings":[]}}"#, ) } @@ -2369,7 +2369,7 @@ mod tests { .build(); ServerTest::new()?.test_body( request, - "{\"head\":{\"vars\":[\"s\",\"p\",\"o\"]},\"results\":{\"bindings\":[]}}", + r#"{"head":{"vars":["s","p","o"]},"results":{"bindings":[]}}"#, ) } @@ -2387,7 +2387,7 @@ mod tests { .build(); ServerTest::new()?.test_body( request, - "{\"head\":{\"vars\":[\"s\",\"p\",\"o\"]},\"results\":{\"bindings\":[]}}", + r#"{"head":{"vars":["s","p","o"]},"results":{"bindings":[]}}"#, ) } @@ -2414,7 +2414,7 @@ mod tests { .build(); ServerTest::new()?.test_body( request, - "{\"head\":{\"vars\":[\"s\",\"p\",\"o\"]},\"results\":{\"bindings\":[]}}", + r#"{"head":{"vars":["s","p","o"]},"results":{"bindings":[]}}"#, ) } @@ -2429,7 +2429,7 @@ mod tests { .build(); ServerTest::new()?.test_body( request, - "{\"head\":{\"vars\":[\"s\",\"p\",\"o\"]},\"results\":{\"bindings\":[]}}", + r#"{"head":{"vars":["s","p","o"]},"results":{"bindings":[]}}"#, ) } #[test] @@ -2679,16 +2679,16 @@ mod tests { let request = Request::builder(Method::PUT, "http://localhost/store/person/1.ttl".parse()?) .with_header(HeaderName::CONTENT_TYPE, "text/turtle; charset=utf-8")? .with_body( - " + r#" @prefix foaf: . @prefix v: . a foaf:Person; foaf:businessCard [ a v:VCard; - v:fn \"John Doe\" + v:fn "John Doe" ]. -", +"#, ); server.test_status(request, Status::CREATED)?; @@ -2717,16 +2717,16 @@ mod tests { let request = Request::builder(Method::PUT, "http://localhost/store/person/1.ttl".parse()?) .with_header(HeaderName::CONTENT_TYPE, "text/turtle; charset=utf-8")? .with_body( - " + r#" @prefix foaf: . @prefix v: . a foaf:Person; foaf:businessCard [ a v:VCard; - v:fn \"Jane Doe\" + v:fn "Jane Doe" ]. -", +"#, ); server.test_status(request, Status::NO_CONTENT)?; @@ -2740,16 +2740,16 @@ mod tests { let request = Request::builder(Method::PUT, "http://localhost/store?default".parse()?) .with_header(HeaderName::CONTENT_TYPE, "text/turtle; charset=utf-8")? .with_body( - " + r#" @prefix foaf: . @prefix v: . [] a foaf:Person; foaf:businessCard [ a v:VCard; - v:given-name \"Alice\" + v:given-name "Alice" ] . -", +"#, ); server.test_status(request, Status::NO_CONTENT)?; // The default graph always exists in Oxigraph @@ -2781,16 +2781,16 @@ mod tests { let request = Request::builder(Method::PUT, "http://localhost/store/person/2.ttl".parse()?) .with_header(HeaderName::CONTENT_TYPE, "text/turtle; charset=utf-8")? .with_body( - " + r#" @prefix foaf: . @prefix v: . [] a foaf:Person; foaf:businessCard [ a v:VCard; - v:given-name \"Alice\" + v:given-name "Alice" ] . -", +"#, ); server.test_status(request, Status::NO_CONTENT)?; @@ -2839,16 +2839,16 @@ mod tests { let request = Request::builder(Method::POST, "http://localhost/store".parse()?) .with_header(HeaderName::CONTENT_TYPE, "text/turtle; charset=utf-8")? .with_body( - " + r#" @prefix foaf: . @prefix v: . [] a foaf:Person; foaf:businessCard [ a v:VCard; - v:given-name \"Alice\" + v:given-name "Alice" ] . -", +"#, ); let response = server.exec(request); assert_eq!(response.status(), Status::CREATED); diff --git a/lib/oxrdf/src/literal.rs b/lib/oxrdf/src/literal.rs index 976b863d..3f2727ca 100644 --- a/lib/oxrdf/src/literal.rs +++ b/lib/oxrdf/src/literal.rs @@ -24,12 +24,12 @@ use std::option::Option; /// ); /// /// assert_eq!( -/// "\"1999-01-01\"^^", +/// r#""1999-01-01"^^"#, /// Literal::new_typed_literal("1999-01-01", xsd::DATE).to_string() /// ); /// /// assert_eq!( -/// "\"foo\"@en", +/// r#""foo"@en"#, /// Literal::new_language_tagged_literal("foo", "en")?.to_string() /// ); /// # Result::<(), LanguageTagParseError>::Ok(()) @@ -436,7 +436,7 @@ impl From for Literal { /// ); /// /// assert_eq!( -/// "\"1999-01-01\"^^", +/// r#""1999-01-01"^^"#, /// LiteralRef::new_typed_literal("1999-01-01", xsd::DATE).to_string() /// ); /// ``` diff --git a/lib/oxrdfxml/README.md b/lib/oxrdfxml/README.md index 8575d19b..29ebb4cf 100644 --- a/lib/oxrdfxml/README.md +++ b/lib/oxrdfxml/README.md @@ -12,31 +12,33 @@ OxRdfXml is a parser and serializer for [RDF/XML](https://www.w3.org/TR/rdf-synt The entry points of this library are the two [`RdfXmlParser`] and [`RdfXmlSerializer`] structs. Usage example counting the number of people in a RDF/XML file: + ```rust use oxrdf::{NamedNodeRef, vocab::rdf}; use oxrdfxml::RdfXmlParser; -let file = b" - - - +fn main() { + let file = br#" + + + Foo - -"; - -let schema_person = NamedNodeRef::new("http://schema.org/Person").unwrap(); -let mut count = 0; -for triple in RdfXmlParser::new().parse_read(file.as_ref()) { - let triple = triple.unwrap(); - if triple.predicate == rdf::TYPE && triple.object == schema_person.into() { - count += 1; + +"#; + + let schema_person = NamedNodeRef::new("http://schema.org/Person").unwrap(); + let mut count = 0; + for triple in RdfXmlParser::new().parse_read(file.as_ref()) { + let triple = triple.unwrap(); + if triple.predicate == rdf::TYPE && triple.object == schema_person.into() { + count += 1; + } } + assert_eq!(2, count); } -assert_eq!(2, count); ``` - ## License This project is licensed under either of diff --git a/lib/oxrdfxml/src/parser.rs b/lib/oxrdfxml/src/parser.rs index ba0b27a1..5a364c78 100644 --- a/lib/oxrdfxml/src/parser.rs +++ b/lib/oxrdfxml/src/parser.rs @@ -29,14 +29,14 @@ use tokio::io::{AsyncRead, BufReader as AsyncBufReader}; /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxrdfxml::RdfXmlParser; /// -/// let file = b" -/// -/// -/// +/// let file = br#" +/// +/// +/// /// Foo /// -/// -/// "; +/// +/// "#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -87,14 +87,14 @@ impl RdfXmlParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxrdfxml::RdfXmlParser; /// - /// let file = b" - /// - /// - /// + /// let file = br#" + /// + /// + /// /// Foo /// - /// - /// "; + /// + /// "#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -124,14 +124,14 @@ impl RdfXmlParser { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxrdfxml::ParseError> { - /// let file = b" - /// - /// - /// + /// let file = br#" + /// + /// + /// /// Foo /// - /// - /// "; + /// + /// "#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; @@ -182,14 +182,14 @@ impl RdfXmlParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxrdfxml::RdfXmlParser; /// -/// let file = b" -/// -/// -/// +/// let file = br#" +/// +/// +/// /// Foo /// -/// -/// "; +/// +/// "#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -251,14 +251,14 @@ impl FromReadRdfXmlReader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxrdfxml::ParseError> { -/// let file = b" -/// -/// -/// +/// let file = br#" +/// +/// +/// /// Foo /// -/// -/// "; +/// +/// "#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; diff --git a/lib/oxttl/src/n3.rs b/lib/oxttl/src/n3.rs index 0642d416..eb1ce55d 100644 --- a/lib/oxttl/src/n3.rs +++ b/lib/oxttl/src/n3.rs @@ -184,12 +184,12 @@ impl From for N3Quad { /// use oxrdf::{NamedNode, vocab::rdf}; /// use oxttl::n3::{N3Parser, N3Term}; /// -/// let file = b"@base . +/// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; -/// schema:name \"Foo\" . +/// schema:name "Foo" . /// a schema:Person ; -/// schema:name \"Bar\" ."; +/// schema:name "Bar" ."#; /// /// let rdf_type = N3Term::NamedNode(rdf::TYPE.into_owned()); /// let schema_person = N3Term::NamedNode(NamedNode::new("http://schema.org/Person")?); @@ -253,12 +253,12 @@ impl N3Parser { /// use oxrdf::NamedNode; /// use oxttl::n3::{N3Parser, N3Term}; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" . + /// schema:name "Foo" . /// a schema:Person ; - /// schema:name \"Bar\" ."; + /// schema:name "Bar" ."#; /// /// let rdf_type = N3Term::NamedNode(NamedNode::new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")?); /// let schema_person = N3Term::NamedNode(NamedNode::new("http://schema.org/Person")?); @@ -287,12 +287,12 @@ impl N3Parser { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" . + /// schema:name "Foo" . /// a schema:Person ; - /// schema:name \"Bar\" ."; + /// schema:name "Bar" ."#; /// /// let rdf_type = N3Term::NamedNode(rdf::TYPE.into_owned()); /// let schema_person = N3Term::NamedNode(NamedNode::new_unchecked("http://schema.org/Person")); @@ -369,12 +369,12 @@ impl N3Parser { /// use oxrdf::{NamedNode, vocab::rdf}; /// use oxttl::n3::{N3Parser, N3Term}; /// -/// let file = b"@base . +/// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; -/// schema:name \"Foo\" . +/// schema:name "Foo" . /// a schema:Person ; -/// schema:name \"Bar\" ."; +/// schema:name "Bar" ."#; /// /// let rdf_type = N3Term::NamedNode(rdf::TYPE.into_owned()); /// let schema_person = N3Term::NamedNode(NamedNode::new("http://schema.org/Person")?); @@ -403,10 +403,10 @@ impl FromReadN3Reader { /// ``` /// use oxttl::N3Parser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = N3Parser::new().parse_read(file.as_ref()); /// assert!(reader.prefixes().is_empty()); // No prefix at the beginning @@ -424,10 +424,10 @@ impl FromReadN3Reader { /// ``` /// use oxttl::N3Parser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = N3Parser::new().parse_read(file.as_ref()); /// assert!(reader.base_iri().is_none()); // No base at the beginning because none has been given to the parser. @@ -464,12 +464,12 @@ impl Iterator for FromReadN3Reader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { -/// let file = b"@base . +/// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; -/// schema:name \"Foo\" . +/// schema:name "Foo" . /// a schema:Person ; -/// schema:name \"Bar\" ."; +/// schema:name "Bar" ."#; /// /// let rdf_type = N3Term::NamedNode(rdf::TYPE.into_owned()); /// let schema_person = N3Term::NamedNode(NamedNode::new_unchecked("http://schema.org/Person")); @@ -509,10 +509,10 @@ impl FromTokioAsyncReadN3Reader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = N3Parser::new().parse_tokio_async_read(file.as_ref()); /// assert!(reader.prefixes().is_empty()); // No prefix at the beginning @@ -533,10 +533,10 @@ impl FromTokioAsyncReadN3Reader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = N3Parser::new().parse_tokio_async_read(file.as_ref()); /// assert!(reader.base_iri().is_none()); // No base IRI at the beginning @@ -633,10 +633,10 @@ impl LowLevelN3Reader { /// ``` /// use oxttl::N3Parser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = N3Parser::new().parse(); /// reader.extend_from_slice(file); @@ -655,10 +655,10 @@ impl LowLevelN3Reader { /// ``` /// use oxttl::N3Parser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = N3Parser::new().parse(); /// reader.extend_from_slice(file); diff --git a/lib/oxttl/src/nquads.rs b/lib/oxttl/src/nquads.rs index 9be1843b..d93c7293 100644 --- a/lib/oxttl/src/nquads.rs +++ b/lib/oxttl/src/nquads.rs @@ -19,10 +19,10 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::NQuadsParser; /// -/// let file = b" . -/// \"Foo\" . +/// let file = br#" . +/// "Foo" . /// . -/// \"Bar\" ."; +/// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -76,10 +76,10 @@ impl NQuadsParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::NQuadsParser; /// - /// let file = b" . - /// \"Foo\" . + /// let file = br#" . + /// "Foo" . /// . - /// \"Bar\" ."; + /// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -107,10 +107,10 @@ impl NQuadsParser { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b" . - /// \"Foo\" . + /// let file = br#" . + /// "Foo" . /// . - /// \"Bar\" ."; + /// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; @@ -191,10 +191,10 @@ impl NQuadsParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::NQuadsParser; /// -/// let file = b" . -/// \"Foo\" . +/// let file = br#" . +/// "Foo" . /// . -/// \"Bar\" ."; +/// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -229,10 +229,10 @@ impl Iterator for FromReadNQuadsReader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { -/// let file = b" . -/// \"Foo\" . +/// let file = br#" . +/// "Foo" . /// . -/// \"Bar\" ."; +/// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; diff --git a/lib/oxttl/src/ntriples.rs b/lib/oxttl/src/ntriples.rs index 995643bc..c5ed5b94 100644 --- a/lib/oxttl/src/ntriples.rs +++ b/lib/oxttl/src/ntriples.rs @@ -19,10 +19,10 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::NTriplesParser; /// -/// let file = b" . -/// \"Foo\" . +/// let file = br#" . +/// "Foo" . /// . -/// \"Bar\" ."; +/// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -76,10 +76,10 @@ impl NTriplesParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::NTriplesParser; /// - /// let file = b" . - /// \"Foo\" . + /// let file = br#" . + /// "Foo" . /// . - /// \"Bar\" ."; + /// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -107,10 +107,10 @@ impl NTriplesParser { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b" . - /// \"Foo\" . + /// let file = br#" . + /// "Foo" . /// . - /// \"Bar\" ."; + /// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; @@ -191,10 +191,10 @@ impl NTriplesParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::NTriplesParser; /// -/// let file = b" . -/// \"Foo\" . +/// let file = br#" . +/// "Foo" . /// . -/// \"Bar\" ."; +/// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -229,10 +229,10 @@ impl Iterator for FromReadNTriplesReader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { -/// let file = b" . -/// \"Foo\" . +/// let file = br#" . +/// "Foo" . /// . -/// \"Bar\" ."; +/// "Bar" ."#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; @@ -565,7 +565,7 @@ mod tests { fn unchecked_parsing() { let triples = NTriplesParser::new() .unchecked() - .parse_read(" \"baz\"@toolonglangtag .".as_bytes()) + .parse_read(r#" "baz"@toolonglangtag ."#.as_bytes()) .collect::, _>>() .unwrap(); assert_eq!( diff --git a/lib/oxttl/src/trig.rs b/lib/oxttl/src/trig.rs index 70d3edb6..08fbf271 100644 --- a/lib/oxttl/src/trig.rs +++ b/lib/oxttl/src/trig.rs @@ -22,12 +22,12 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::TriGParser; /// -/// let file = b"@base . +/// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; -/// schema:name \"Foo\" . +/// schema:name "Foo" . /// a schema:Person ; -/// schema:name \"Bar\" ."; +/// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -100,12 +100,12 @@ impl TriGParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::TriGParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" . + /// schema:name "Foo" . /// a schema:Person ; - /// schema:name \"Bar\" ."; + /// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -133,12 +133,12 @@ impl TriGParser { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" . + /// schema:name "Foo" . /// a schema:Person ; - /// schema:name \"Bar\" ."; + /// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; @@ -220,12 +220,12 @@ impl TriGParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::TriGParser; /// -/// let file = b"@base . +/// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; -/// schema:name \"Foo\" . +/// schema:name "Foo" . /// a schema:Person ; -/// schema:name \"Bar\" ."; +/// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -253,10 +253,10 @@ impl FromReadTriGReader { /// ``` /// use oxttl::TriGParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TriGParser::new().parse_read(file.as_ref()); /// assert!(reader.prefixes().is_empty()); // No prefix at the beginning @@ -274,10 +274,10 @@ impl FromReadTriGReader { /// ``` /// use oxttl::TriGParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TriGParser::new().parse_read(file.as_ref()); /// assert!(reader.base_iri().is_none()); // No base at the beginning because none has been given to the parser. @@ -314,12 +314,12 @@ impl Iterator for FromReadTriGReader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { -/// let file = b"@base . +/// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; -/// schema:name \"Foo\" . +/// schema:name "Foo" . /// a schema:Person ; -/// schema:name \"Bar\" ."; +/// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; @@ -358,10 +358,10 @@ impl FromTokioAsyncReadTriGReader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TriGParser::new().parse_tokio_async_read(file.as_ref()); /// assert!(reader.prefixes().is_empty()); // No prefix at the beginning @@ -382,10 +382,10 @@ impl FromTokioAsyncReadTriGReader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TriGParser::new().parse_tokio_async_read(file.as_ref()); /// assert!(reader.base_iri().is_none()); // No base IRI at the beginning @@ -481,10 +481,10 @@ impl LowLevelTriGReader { /// ``` /// use oxttl::TriGParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TriGParser::new().parse(); /// reader.extend_from_slice(file); @@ -503,10 +503,10 @@ impl LowLevelTriGReader { /// ``` /// use oxttl::TriGParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TriGParser::new().parse(); /// reader.extend_from_slice(file); diff --git a/lib/oxttl/src/turtle.rs b/lib/oxttl/src/turtle.rs index 0e225611..19590b94 100644 --- a/lib/oxttl/src/turtle.rs +++ b/lib/oxttl/src/turtle.rs @@ -24,12 +24,12 @@ use tokio::io::{AsyncRead, AsyncWrite}; /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::TurtleParser; /// -/// let file = b"@base . +/// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; -/// schema:name \"Foo\" . +/// schema:name "Foo" . /// a schema:Person ; -/// schema:name \"Bar\" ."; +/// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -102,12 +102,12 @@ impl TurtleParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::TurtleParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" . + /// schema:name "Foo" . /// a schema:Person ; - /// schema:name \"Bar\" ."; + /// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -135,12 +135,12 @@ impl TurtleParser { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" . + /// schema:name "Foo" . /// a schema:Person ; - /// schema:name \"Bar\" ."; + /// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; @@ -222,12 +222,12 @@ impl TurtleParser { /// use oxrdf::{NamedNodeRef, vocab::rdf}; /// use oxttl::TurtleParser; /// -/// let file = b"@base . +/// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; -/// schema:name \"Foo\" . +/// schema:name "Foo" . /// a schema:Person ; -/// schema:name \"Bar\" ."; +/// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new("http://schema.org/Person")?; /// let mut count = 0; @@ -255,10 +255,10 @@ impl FromReadTurtleReader { /// ``` /// use oxttl::TurtleParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TurtleParser::new().parse_read(file.as_ref()); /// assert!(reader.prefixes().is_empty()); // No prefix at the beginning @@ -276,10 +276,10 @@ impl FromReadTurtleReader { /// ``` /// use oxttl::TurtleParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TurtleParser::new().parse_read(file.as_ref()); /// assert!(reader.base_iri().is_none()); // No base at the beginning because none has been given to the parser. @@ -316,12 +316,12 @@ impl Iterator for FromReadTurtleReader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { -/// let file = b"@base . +/// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; -/// schema:name \"Foo\" . +/// schema:name "Foo" . /// a schema:Person ; -/// schema:name \"Bar\" ."; +/// schema:name "Bar" ."#; /// /// let schema_person = NamedNodeRef::new_unchecked("http://schema.org/Person"); /// let mut count = 0; @@ -360,10 +360,10 @@ impl FromTokioAsyncReadTurtleReader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TurtleParser::new().parse_tokio_async_read(file.as_ref()); /// assert!(reader.prefixes().is_empty()); // No prefix at the beginning @@ -384,10 +384,10 @@ impl FromTokioAsyncReadTurtleReader { /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), oxttl::ParseError> { - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TurtleParser::new().parse_tokio_async_read(file.as_ref()); /// assert!(reader.base_iri().is_none()); // No base IRI at the beginning @@ -483,10 +483,10 @@ impl LowLevelTurtleReader { /// ``` /// use oxttl::TurtleParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TurtleParser::new().parse(); /// reader.extend_from_slice(file); @@ -505,10 +505,10 @@ impl LowLevelTurtleReader { /// ``` /// use oxttl::TurtleParser; /// - /// let file = b"@base . + /// let file = br#"@base . /// @prefix schema: . /// a schema:Person ; - /// schema:name \"Foo\" ."; + /// schema:name "Foo" ."#; /// /// let mut reader = TurtleParser::new().parse(); /// reader.extend_from_slice(file); diff --git a/lib/sparesults/src/parser.rs b/lib/sparesults/src/parser.rs index 0a826e96..3e521fe8 100644 --- a/lib/sparesults/src/parser.rs +++ b/lib/sparesults/src/parser.rs @@ -22,11 +22,11 @@ use std::sync::Arc; /// /// let json_parser = QueryResultsParser::from_format(QueryResultsFormat::Json); /// // boolean -/// if let FromReadQueryResultsReader::Boolean(v) = json_parser.parse_read(b"{\"boolean\":true}".as_slice())? { +/// if let FromReadQueryResultsReader::Boolean(v) = json_parser.parse_read(br#"{"boolean":true}"#.as_slice())? { /// assert_eq!(v, true); /// } /// // solutions -/// if let FromReadQueryResultsReader::Solutions(solutions) = json_parser.parse_read(b"{\"head\":{\"vars\":[\"foo\",\"bar\"]},\"results\":{\"bindings\":[{\"foo\":{\"type\":\"literal\",\"value\":\"test\"}}]}}".as_slice())? { +/// if let FromReadQueryResultsReader::Solutions(solutions) = json_parser.parse_read(br#"{"head":{"vars":["foo","bar"]},"results":{"bindings":[{"foo":{"type":"literal","value":"test"}}]}}"#.as_slice())? { /// assert_eq!(solutions.variables(), &[Variable::new_unchecked("foo"), Variable::new_unchecked("bar")]); /// for solution in solutions { /// assert_eq!(solution?.iter().collect::>(), vec![(&Variable::new_unchecked("foo"), &Literal::from("test").into())]); @@ -57,12 +57,12 @@ impl QueryResultsParser { /// let json_parser = QueryResultsParser::from_format(QueryResultsFormat::Xml); /// /// // boolean - /// if let FromReadQueryResultsReader::Boolean(v) = json_parser.parse_read(b"true".as_slice())? { + /// if let FromReadQueryResultsReader::Boolean(v) = json_parser.parse_read(br#"true"#.as_slice())? { /// assert_eq!(v, true); /// } /// /// // solutions - /// if let FromReadQueryResultsReader::Solutions(solutions) = json_parser.parse_read(b"test".as_slice())? { + /// if let FromReadQueryResultsReader::Solutions(solutions) = json_parser.parse_read(br#"test"#.as_slice())? { /// assert_eq!(solutions.variables(), &[Variable::new_unchecked("foo"), Variable::new_unchecked("bar")]); /// for solution in solutions { /// assert_eq!(solution?.iter().collect::>(), vec![(&Variable::new_unchecked("foo"), &Literal::from("test").into())]); @@ -164,7 +164,7 @@ pub enum FromReadQueryResultsReader { /// use oxrdf::{Literal, Variable}; /// /// let json_parser = QueryResultsParser::from_format(QueryResultsFormat::Json); -/// if let FromReadQueryResultsReader::Solutions(solutions) = json_parser.parse_read(b"{\"head\":{\"vars\":[\"foo\",\"bar\"]},\"results\":{\"bindings\":[{\"foo\":{\"type\":\"literal\",\"value\":\"test\"}}]}}".as_slice())? { +/// if let FromReadQueryResultsReader::Solutions(solutions) = json_parser.parse_read(br#"{"head":{"vars":["foo","bar"]},"results":{"bindings":[{"foo":{"type":"literal","value":"test"}}]}}"#.as_slice())? { /// assert_eq!(solutions.variables(), &[Variable::new_unchecked("foo"), Variable::new_unchecked("bar")]); /// for solution in solutions { /// assert_eq!(solution?.iter().collect::>(), vec![(&Variable::new_unchecked("foo"), &Literal::from("test").into())]); diff --git a/lib/sparesults/src/serializer.rs b/lib/sparesults/src/serializer.rs index 9a4ba143..13c21628 100644 --- a/lib/sparesults/src/serializer.rs +++ b/lib/sparesults/src/serializer.rs @@ -35,14 +35,14 @@ use tokio::io::AsyncWrite; /// // boolean /// let mut buffer = Vec::new(); /// json_serializer.serialize_boolean_to_write(&mut buffer, true)?; -/// assert_eq!(buffer, b"{\"head\":{},\"boolean\":true}"); +/// assert_eq!(buffer, br#"{"head":{},"boolean":true}"#); /// /// // solutions /// let mut buffer = Vec::new(); /// let mut writer = json_serializer.serialize_solutions_to_write(&mut buffer, vec![Variable::new_unchecked("foo"), Variable::new_unchecked("bar")])?; /// writer.write(once((VariableRef::new_unchecked("foo"), LiteralRef::from("test"))))?; /// writer.finish()?; -/// assert_eq!(buffer, b"{\"head\":{\"vars\":[\"foo\",\"bar\"]},\"results\":{\"bindings\":[{\"foo\":{\"type\":\"literal\",\"value\":\"test\"}}]}}"); +/// assert_eq!(buffer, br#"{"head":{"vars":["foo","bar"]},"results":{"bindings":[{"foo":{"type":"literal","value":"test"}}]}}"#); /// # std::io::Result::Ok(()) /// ``` pub struct QueryResultsSerializer { @@ -65,7 +65,7 @@ impl QueryResultsSerializer { /// let xml_serializer = QueryResultsSerializer::from_format(QueryResultsFormat::Xml); /// let mut buffer = Vec::new(); /// xml_serializer.serialize_boolean_to_write(&mut buffer, true)?; - /// assert_eq!(buffer, b"true"); + /// assert_eq!(buffer, br#"true"#); /// # std::io::Result::Ok(()) /// ``` pub fn serialize_boolean_to_write(&self, write: W, value: bool) -> io::Result { @@ -89,7 +89,7 @@ impl QueryResultsSerializer { /// let json_serializer = QueryResultsSerializer::from_format(QueryResultsFormat::Json); /// let mut buffer = Vec::new(); /// json_serializer.serialize_boolean_to_tokio_async_write(&mut buffer, false).await?; - /// assert_eq!(buffer, b"{\"head\":{},\"boolean\":false}"); + /// assert_eq!(buffer, br#"{"head":{},"boolean":false}"r); /// # Ok(()) /// # } /// ``` @@ -134,7 +134,7 @@ impl QueryResultsSerializer { /// let mut writer = xml_serializer.serialize_solutions_to_write(&mut buffer, vec![Variable::new_unchecked("foo"), Variable::new_unchecked("bar")])?; /// writer.write(once((VariableRef::new_unchecked("foo"), LiteralRef::from("test"))))?; /// writer.finish()?; - /// assert_eq!(buffer, b"test"); + /// assert_eq!(buffer, br#"test"#); /// # std::io::Result::Ok(()) /// ``` pub fn serialize_solutions_to_write( @@ -183,7 +183,7 @@ impl QueryResultsSerializer { /// let mut writer = json_serializer.serialize_solutions_to_tokio_async_write(&mut buffer, vec![Variable::new_unchecked("foo"), Variable::new_unchecked("bar")]).await?; /// writer.write(once((VariableRef::new_unchecked("foo"), LiteralRef::from("test")))).await?; /// writer.finish().await?; - /// assert_eq!(buffer, b"{\"head\":{\"vars\":[\"foo\",\"bar\"]},\"results\":{\"bindings\":[{\"foo\":{\"type\":\"literal\",\"value\":\"test\"}}]}}"); + /// assert_eq!(buffer, br#"{"head":{"vars":["foo","bar"]},"results":{"bindings":[{"foo":{"type":"literal","value":"test"}}]}}"#); /// # Ok(()) /// # } /// ``` @@ -280,7 +280,7 @@ impl ToWriteSolutionsWriter { /// writer.write(once((VariableRef::new_unchecked("foo"), LiteralRef::from("test"))))?; /// writer.write(&QuerySolution::from((vec![Variable::new_unchecked("bar")], vec![Some(Literal::from("test").into())])))?; /// writer.finish()?; - /// assert_eq!(buffer, b"{\"head\":{\"vars\":[\"foo\",\"bar\"]},\"results\":{\"bindings\":[{\"foo\":{\"type\":\"literal\",\"value\":\"test\"}},{\"bar\":{\"type\":\"literal\",\"value\":\"test\"}}]}}"); + /// assert_eq!(buffer, br#"{"head":{"vars":["foo","bar"]},"results":{"bindings":[{"foo":{"type":"literal","value":"test"}},{"bar":{"type":"literal","value":"test"}}]}}"#); /// # std::io::Result::Ok(()) /// ``` pub fn write<'a>( @@ -368,7 +368,7 @@ impl ToTokioAsyncWriteSolutionsWriter { /// writer.write(once((VariableRef::new_unchecked("foo"), LiteralRef::from("test")))).await?; /// writer.write(&QuerySolution::from((vec![Variable::new_unchecked("bar")], vec![Some(Literal::from("test").into())]))).await?; /// writer.finish().await?; - /// assert_eq!(buffer, b"{\"head\":{\"vars\":[\"foo\",\"bar\"]},\"results\":{\"bindings\":[{\"foo\":{\"type\":\"literal\",\"value\":\"test\"}},{\"bar\":{\"type\":\"literal\",\"value\":\"test\"}}]}}"); + /// assert_eq!(buffer, br#"{"head":{"vars":["foo","bar"]},"results":{"bindings":[{"foo":{"type":"literal","value":"test"}},{"bar":{"type":"literal","value":"test"}}]}}"#); /// # Ok(()) /// # } /// ``` diff --git a/lib/src/sparql/model.rs b/lib/src/sparql/model.rs index 326e7603..faedc7f5 100644 --- a/lib/src/sparql/model.rs +++ b/lib/src/sparql/model.rs @@ -43,7 +43,7 @@ impl QueryResults { /// /// let mut results = Vec::new(); /// store.query("SELECT ?s WHERE { ?s ?p ?o }")?.write(&mut results, QueryResultsFormat::Json)?; - /// assert_eq!(results, "{\"head\":{\"vars\":[\"s\"]},\"results\":{\"bindings\":[{\"s\":{\"type\":\"uri\",\"value\":\"http://example.com\"}}]}}".as_bytes()); + /// assert_eq!(results, r#"{"head":{"vars":["s"]},"results":{"bindings":[{"s":{"type":"uri","value":"http://example.com"}}]}}"#.as_bytes()); /// # Result::<_,Box>::Ok(()) /// ``` pub fn write( diff --git a/lib/src/sparql/results.rs b/lib/src/sparql/results.rs index bbafe70d..88aff947 100644 --- a/lib/src/sparql/results.rs +++ b/lib/src/sparql/results.rs @@ -30,13 +30,13 @@ //! //! // Let's test with a boolean //! assert_eq!( -//! convert_json_to_tsv(b"{\"boolean\":true}".as_slice()).unwrap(), +//! convert_json_to_tsv(br#"{"boolean":true}"#.as_slice()).unwrap(), //! b"true" //! ); //! //! // And with a set of solutions //! assert_eq!( -//! convert_json_to_tsv(b"{\"head\":{\"vars\":[\"foo\",\"bar\"]},\"results\":{\"bindings\":[{\"foo\":{\"type\":\"literal\",\"value\":\"test\"}}]}}".as_slice()).unwrap(), +//! convert_json_to_tsv(br#"{"head":{"vars":["foo","bar"]},"results":{"bindings":[{"foo":{"type":"literal","value":"test"}}]}}"#.as_slice()).unwrap(), //! b"?foo\t?bar\n\"test\"\t\n" //! ); //! ```