@ -16,15 +16,15 @@ use std::fmt::Write;
/// NamedNode { iri: "http://example.com/foo".into() }.to_string()
/// NamedNode { iri: "http://example.com/foo".into() }.to_string()
/// )
/// )
/// ```
/// ```
#[ derive(Eq, PartialEq, Ord, PartialOrd, Clone, Hash) ]
#[ derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash) ]
pub struct NamedNode {
pub struct NamedNode {
/// The [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) itself.
/// The [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) itself.
pub iri : String ,
pub iri : String ,
}
}
impl fmt ::Debug for NamedNode {
impl NamedNode {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
write! ( f , "<{}>" , self . iri )
write! ( f , "<{}>" , self . iri )
}
}
}
}
@ -61,15 +61,15 @@ impl TryFrom<NamedNodePattern> for NamedNode {
/// BlankNode { id: "a1".into() }.to_string()
/// BlankNode { id: "a1".into() }.to_string()
/// )
/// )
/// ```
/// ```
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub struct BlankNode {
pub struct BlankNode {
/// The [blank node identifier](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node-identifier).
/// The [blank node identifier](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node-identifier).
pub id : String ,
pub id : String ,
}
}
impl fmt ::Debug for BlankNode {
impl BlankNode {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
write! ( f , "_:{}" , self . id )
write! ( f , "_:{}" , self . id )
}
}
}
}
@ -106,7 +106,7 @@ impl fmt::Display for BlankNode {
/// Literal::LanguageTaggedString { value: "foo".into(), language: "en".into() }.to_string()
/// Literal::LanguageTaggedString { value: "foo".into(), language: "en".into() }.to_string()
/// );
/// );
/// ```
/// ```
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum Literal {
pub enum Literal {
/// A [simple literal](https://www.w3.org/TR/rdf11-concepts/#dfn-simple-literal) without datatype or language form.
/// A [simple literal](https://www.w3.org/TR/rdf11-concepts/#dfn-simple-literal) without datatype or language form.
Simple {
Simple {
@ -129,9 +129,9 @@ pub enum Literal {
} ,
} ,
}
}
impl fmt ::Debug for Literal {
impl Literal {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Literal ::Simple { value } = > print_quoted_str ( value , f ) ,
Literal ::Simple { value } = > print_quoted_str ( value , f ) ,
Literal ::LanguageTaggedString { value , language } = > {
Literal ::LanguageTaggedString { value , language } = > {
@ -166,7 +166,7 @@ impl fmt::Display for Literal {
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node).
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node).
///
///
/// The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
/// The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum Subject {
pub enum Subject {
NamedNode ( NamedNode ) ,
NamedNode ( NamedNode ) ,
BlankNode ( BlankNode ) ,
BlankNode ( BlankNode ) ,
@ -174,14 +174,14 @@ pub enum Subject {
Triple ( Box < Triple > ) ,
Triple ( Box < Triple > ) ,
}
}
impl fmt ::Debug for Subject {
impl Subject {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Self ::NamedNode ( node ) = > node . fmt ( f ) ,
Self ::NamedNode ( node ) = > node . fmt_sse ( f ) ,
Self ::BlankNode ( node ) = > node . fmt ( f ) ,
Self ::BlankNode ( node ) = > node . fmt_sse ( f ) ,
#[ cfg(feature = " rdf-star " ) ]
#[ cfg(feature = " rdf-star " ) ]
Self ::Triple ( triple ) = > triple . fmt ( f ) ,
Self ::Triple ( triple ) = > triple . fmt_sse ( f ) ,
}
}
}
}
}
}
@ -242,20 +242,20 @@ impl TryFrom<TermPattern> for Subject {
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple).
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple).
///
///
/// The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
/// The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum GroundSubject {
pub enum GroundSubject {
NamedNode ( NamedNode ) ,
NamedNode ( NamedNode ) ,
#[ cfg(feature = " rdf-star " ) ]
#[ cfg(feature = " rdf-star " ) ]
Triple ( Box < GroundTriple > ) ,
Triple ( Box < GroundTriple > ) ,
}
}
impl fmt ::Debug for GroundSubject {
impl GroundSubject {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Self ::NamedNode ( node ) = > node . fmt ( f ) ,
Self ::NamedNode ( node ) = > node . fmt_sse ( f ) ,
#[ cfg(feature = " rdf-star " ) ]
#[ cfg(feature = " rdf-star " ) ]
Self ::Triple ( triple ) = > triple . fmt ( f ) ,
Self ::Triple ( triple ) = > triple . fmt_sse ( f ) ,
}
}
}
}
}
}
@ -323,7 +323,7 @@ impl TryFrom<GroundTerm> for GroundSubject {
/// It is the union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node) and [literals](https://www.w3.org/TR/rdf11-concepts/#dfn-literal).
/// It is the union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node) and [literals](https://www.w3.org/TR/rdf11-concepts/#dfn-literal).
///
///
/// The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
/// The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum Term {
pub enum Term {
NamedNode ( NamedNode ) ,
NamedNode ( NamedNode ) ,
BlankNode ( BlankNode ) ,
BlankNode ( BlankNode ) ,
@ -332,15 +332,15 @@ pub enum Term {
Triple ( Box < Triple > ) ,
Triple ( Box < Triple > ) ,
}
}
impl fmt ::Debug for Term {
impl Term {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Self ::NamedNode ( node ) = > node . fmt ( f ) ,
Self ::NamedNode ( node ) = > node . fmt_sse ( f ) ,
Self ::BlankNode ( node ) = > node . fmt ( f ) ,
Self ::BlankNode ( node ) = > node . fmt_sse ( f ) ,
Self ::Literal ( literal ) = > literal . fmt ( f ) ,
Self ::Literal ( literal ) = > literal . fmt_sse ( f ) ,
#[ cfg(feature = " rdf-star " ) ]
#[ cfg(feature = " rdf-star " ) ]
Self ::Triple ( triple ) = > triple . fmt ( f ) ,
Self ::Triple ( triple ) = > triple . fmt_sse ( f ) ,
}
}
}
}
}
}
@ -422,7 +422,7 @@ impl TryFrom<TermPattern> for Term {
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [literals](https://www.w3.org/TR/rdf11-concepts/#dfn-literal) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple).
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [literals](https://www.w3.org/TR/rdf11-concepts/#dfn-literal) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple).
///
///
/// The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
/// The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum GroundTerm {
pub enum GroundTerm {
NamedNode ( NamedNode ) ,
NamedNode ( NamedNode ) ,
Literal ( Literal ) ,
Literal ( Literal ) ,
@ -430,14 +430,14 @@ pub enum GroundTerm {
Triple ( Box < GroundTriple > ) ,
Triple ( Box < GroundTriple > ) ,
}
}
impl fmt ::Debug for GroundTerm {
impl GroundTerm {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Self ::NamedNode ( node ) = > node . fmt ( f ) ,
Self ::NamedNode ( node ) = > node . fmt_sse ( f ) ,
Self ::Literal ( literal ) = > literal . fmt ( f ) ,
Self ::Literal ( literal ) = > literal . fmt_sse ( f ) ,
#[ cfg(feature = " rdf-star " ) ]
#[ cfg(feature = " rdf-star " ) ]
Self ::Triple ( triple ) = > triple . fmt ( f ) ,
Self ::Triple ( triple ) = > triple . fmt_sse ( f ) ,
}
}
}
}
}
}
@ -512,21 +512,23 @@ impl TryFrom<Term> for GroundTerm {
/// }.to_string()
/// }.to_string()
/// )
/// )
/// ```
/// ```
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub struct Triple {
pub struct Triple {
pub subject : Subject ,
pub subject : Subject ,
pub predicate : NamedNode ,
pub predicate : NamedNode ,
pub object : Term ,
pub object : Term ,
}
}
impl fmt ::Debug for Triple {
impl Triple {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
write! (
write! ( f , "(triple " ) ? ;
f ,
self . subject . fmt_sse ( f ) ? ;
"(triple {:?} {:?} {:?})" ,
write! ( f , " " ) ? ;
self . subject , self . predicate , self . object
self . predicate . fmt_sse ( f ) ? ;
)
write! ( f , " " ) ? ;
self . object . fmt_sse ( f ) ? ;
write! ( f , ")" )
}
}
}
}
@ -567,21 +569,23 @@ impl TryFrom<TriplePattern> for Triple {
/// }.to_string()
/// }.to_string()
/// )
/// )
/// ```
/// ```
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub struct GroundTriple {
pub struct GroundTriple {
pub subject : GroundSubject ,
pub subject : GroundSubject ,
pub predicate : NamedNode ,
pub predicate : NamedNode ,
pub object : GroundTerm ,
pub object : GroundTerm ,
}
}
impl fmt ::Debug for GroundTriple {
impl GroundTriple {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
write! (
write! ( f , "(triple " ) ? ;
f ,
self . subject . fmt_sse ( f ) ? ;
"(triple {:?} {:?} {:?})" ,
write! ( f , " " ) ? ;
self . subject , self . predicate , self . object
self . predicate . fmt_sse ( f ) ? ;
)
write! ( f , " " ) ? ;
self . object . fmt_sse ( f ) ? ;
write! ( f , ")" )
}
}
}
}
@ -608,17 +612,17 @@ impl TryFrom<Triple> for GroundTriple {
/// A possible graph name.
/// A possible graph name.
///
///
/// It is the union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and the [default graph name](https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph).
/// It is the union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and the [default graph name](https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph).
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum GraphName {
pub enum GraphName {
NamedNode ( NamedNode ) ,
NamedNode ( NamedNode ) ,
DefaultGraph ,
DefaultGraph ,
}
}
impl fmt ::Debug for GraphName {
impl GraphName {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Self ::NamedNode ( node ) = > node . fmt ( f ) ,
Self ::NamedNode ( node ) = > node . fmt_sse ( f ) ,
Self ::DefaultGraph = > write! ( f , "default" ) ,
Self ::DefaultGraph = > write! ( f , "default" ) ,
}
}
}
}
@ -672,7 +676,7 @@ impl TryFrom<GraphNamePattern> for GraphName {
/// }.to_string()
/// }.to_string()
/// )
/// )
/// ```
/// ```
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub struct Quad {
pub struct Quad {
pub subject : Subject ,
pub subject : Subject ,
pub predicate : NamedNode ,
pub predicate : NamedNode ,
@ -680,22 +684,25 @@ pub struct Quad {
pub graph_name : GraphName ,
pub graph_name : GraphName ,
}
}
impl fmt ::Debug for Quad {
impl Quad {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
if self . graph_name = = GraphName ::DefaultGraph {
if self . graph_name ! = GraphName ::DefaultGraph {
write! (
write! ( f , "(graph " ) ? ;
f ,
self . graph_name . fmt_sse ( f ) ? ;
"(triple {:?} {:?} {:?})" ,
write! ( f , " (" ) ? ;
self . subject , self . predicate , self . object
}
)
write! ( f , "(triple " ) ? ;
} else {
self . subject . fmt_sse ( f ) ? ;
write! (
write! ( f , " " ) ? ;
f ,
self . predicate . fmt_sse ( f ) ? ;
"(graph {:?} ((triple {:?} {:?} {:?})))" ,
write! ( f , " " ) ? ;
self . graph_name , self . subject , self . predicate , self . object
self . object . fmt_sse ( f ) ? ;
)
write! ( f , ")" ) ? ;
if self . graph_name ! = GraphName ::DefaultGraph {
write! ( f , "))" ) ? ;
}
}
Ok ( ( ) )
}
}
}
}
@ -746,7 +753,7 @@ impl TryFrom<QuadPattern> for Quad {
/// }.to_string()
/// }.to_string()
/// )
/// )
/// ```
/// ```
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub struct GroundQuad {
pub struct GroundQuad {
pub subject : GroundSubject ,
pub subject : GroundSubject ,
pub predicate : NamedNode ,
pub predicate : NamedNode ,
@ -754,22 +761,25 @@ pub struct GroundQuad {
pub graph_name : GraphName ,
pub graph_name : GraphName ,
}
}
impl fmt ::Debug for GroundQuad {
impl GroundQuad {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
if self . graph_name = = GraphName ::DefaultGraph {
if self . graph_name ! = GraphName ::DefaultGraph {
write! (
write! ( f , "(graph " ) ? ;
f ,
self . graph_name . fmt_sse ( f ) ? ;
"(triple {:?} {:?} {:?})" ,
write! ( f , " (" ) ? ;
self . subject , self . predicate , self . object
}
)
write! ( f , "(triple " ) ? ;
} else {
self . subject . fmt_sse ( f ) ? ;
write! (
write! ( f , " " ) ? ;
f ,
self . predicate . fmt_sse ( f ) ? ;
"(graph {:?} ((triple {:?} {:?} {:?})))" ,
write! ( f , " " ) ? ;
self . graph_name , self . subject , self . predicate , self . object
self . object . fmt_sse ( f ) ? ;
)
write! ( f , ")" ) ? ;
if self . graph_name ! = GraphName ::DefaultGraph {
write! ( f , "))" ) ? ;
}
}
Ok ( ( ) )
}
}
}
}
@ -812,14 +822,14 @@ impl TryFrom<Quad> for GroundQuad {
/// Variable { name: "foo".into() }.to_string()
/// Variable { name: "foo".into() }.to_string()
/// );
/// );
/// ```
/// ```
#[ derive(Eq, PartialEq, Ord, PartialOrd, Clone, Hash) ]
#[ derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash) ]
pub struct Variable {
pub struct Variable {
pub name : String ,
pub name : String ,
}
}
impl fmt ::Debug for Variable {
impl Variable {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
write! ( f , "?{}" , self . name )
write! ( f , "?{}" , self . name )
}
}
}
}
@ -832,18 +842,18 @@ impl fmt::Display for Variable {
}
}
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and [variables](https://www.w3.org/TR/sparql11-query/#sparqlQueryVariables).
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and [variables](https://www.w3.org/TR/sparql11-query/#sparqlQueryVariables).
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum NamedNodePattern {
pub enum NamedNodePattern {
NamedNode ( NamedNode ) ,
NamedNode ( NamedNode ) ,
Variable ( Variable ) ,
Variable ( Variable ) ,
}
}
impl fmt ::Debug for NamedNodePattern {
impl NamedNodePattern {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Self ::NamedNode ( node ) = > node . fmt ( f ) ,
Self ::NamedNode ( node ) = > node . fmt_sse ( f ) ,
Self ::Variable ( var ) = > var . fmt ( f ) ,
Self ::Variable ( var ) = > var . fmt_sse ( f ) ,
}
}
}
}
}
}
@ -873,7 +883,7 @@ impl From<Variable> for NamedNodePattern {
}
}
/// The union of [terms](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term) and [variables](https://www.w3.org/TR/sparql11-query/#sparqlQueryVariables).
/// The union of [terms](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term) and [variables](https://www.w3.org/TR/sparql11-query/#sparqlQueryVariables).
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum TermPattern {
pub enum TermPattern {
NamedNode ( NamedNode ) ,
NamedNode ( NamedNode ) ,
BlankNode ( BlankNode ) ,
BlankNode ( BlankNode ) ,
@ -883,16 +893,16 @@ pub enum TermPattern {
Variable ( Variable ) ,
Variable ( Variable ) ,
}
}
impl fmt ::Debug for TermPattern {
impl TermPattern {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Self ::NamedNode ( term ) = > term . fmt ( f ) ,
Self ::NamedNode ( term ) = > term . fmt_sse ( f ) ,
Self ::BlankNode ( term ) = > term . fmt ( f ) ,
Self ::BlankNode ( term ) = > term . fmt_sse ( f ) ,
Self ::Literal ( term ) = > term . fmt ( f ) ,
Self ::Literal ( term ) = > term . fmt_sse ( f ) ,
#[ cfg(feature = " rdf-star " ) ]
#[ cfg(feature = " rdf-star " ) ]
Self ::Triple ( triple ) = > triple . fmt ( f ) ,
Self ::Triple ( triple ) = > triple . fmt_sse ( f ) ,
Self ::Variable ( var ) = > var . fmt ( f ) ,
Self ::Variable ( var ) = > var . fmt_sse ( f ) ,
}
}
}
}
}
}
@ -982,7 +992,7 @@ impl From<NamedNodePattern> for TermPattern {
}
}
/// The union of [terms](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term) and [variables](https://www.w3.org/TR/sparql11-query/#sparqlQueryVariables) without blank nodes.
/// The union of [terms](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term) and [variables](https://www.w3.org/TR/sparql11-query/#sparqlQueryVariables) without blank nodes.
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum GroundTermPattern {
pub enum GroundTermPattern {
NamedNode ( NamedNode ) ,
NamedNode ( NamedNode ) ,
Literal ( Literal ) ,
Literal ( Literal ) ,
@ -990,14 +1000,14 @@ pub enum GroundTermPattern {
Triple ( Box < GroundTriplePattern > ) ,
Triple ( Box < GroundTriplePattern > ) ,
}
}
impl fmt ::Debug for GroundTermPattern {
impl GroundTermPattern {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Self ::NamedNode ( term ) = > term . fmt ( f ) ,
Self ::NamedNode ( term ) = > term . fmt_sse ( f ) ,
Self ::Literal ( term ) = > term . fmt ( f ) ,
Self ::Literal ( term ) = > term . fmt_sse ( f ) ,
Self ::Variable ( var ) = > var . fmt ( f ) ,
Self ::Variable ( var ) = > var . fmt_sse ( f ) ,
Self ::Triple ( triple ) = > write! ( f , "<<{}>>" , triple ) ,
Self ::Triple ( triple ) = > triple . fmt_sse ( f ) ,
}
}
}
}
}
}
@ -1091,20 +1101,20 @@ impl TryFrom<TermPattern> for GroundTermPattern {
}
}
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [default graph name](https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph) and [variables](https://www.w3.org/TR/sparql11-query/#sparqlQueryVariables).
/// The union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [default graph name](https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph) and [variables](https://www.w3.org/TR/sparql11-query/#sparqlQueryVariables).
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub enum GraphNamePattern {
pub enum GraphNamePattern {
NamedNode ( NamedNode ) ,
NamedNode ( NamedNode ) ,
DefaultGraph ,
DefaultGraph ,
Variable ( Variable ) ,
Variable ( Variable ) ,
}
}
impl fmt ::Debug for GraphNamePattern {
impl GraphNamePattern {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
match self {
match self {
Self ::NamedNode ( node ) = > node . fmt ( f ) ,
Self ::NamedNode ( node ) = > node . fmt_sse ( f ) ,
Self ::DefaultGraph = > write! ( f , "default" ) ,
Self ::DefaultGraph = > write! ( f , "default" ) ,
Self ::Variable ( var ) = > var . fmt ( f ) ,
Self ::Variable ( var ) = > var . fmt_sse ( f ) ,
}
}
}
}
}
}
@ -1155,7 +1165,7 @@ impl From<NamedNodePattern> for GraphNamePattern {
}
}
/// A [triple pattern](https://www.w3.org/TR/sparql11-query/#defn_TriplePattern)
/// A [triple pattern](https://www.w3.org/TR/sparql11-query/#defn_TriplePattern)
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub struct TriplePattern {
pub struct TriplePattern {
pub subject : TermPattern ,
pub subject : TermPattern ,
pub predicate : NamedNodePattern ,
pub predicate : NamedNodePattern ,
@ -1176,14 +1186,16 @@ impl TriplePattern {
}
}
}
}
impl fmt ::Debug for TriplePattern {
impl TriplePattern {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
write! (
write! ( f , "(triple " ) ? ;
f ,
self . subject . fmt_sse ( f ) ? ;
"(triple {:?} {:?} {:?})" ,
write! ( f , " " ) ? ;
self . subject , self . predicate , self . object
self . predicate . fmt_sse ( f ) ? ;
)
write! ( f , " " ) ? ;
self . object . fmt_sse ( f ) ? ;
write! ( f , ")" )
}
}
}
}
@ -1206,21 +1218,23 @@ impl From<Triple> for TriplePattern {
}
}
/// A [triple pattern](https://www.w3.org/TR/sparql11-query/#defn_TriplePattern) without blank nodes
/// A [triple pattern](https://www.w3.org/TR/sparql11-query/#defn_TriplePattern) without blank nodes
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub struct GroundTriplePattern {
pub struct GroundTriplePattern {
pub subject : GroundTermPattern ,
pub subject : GroundTermPattern ,
pub predicate : NamedNodePattern ,
pub predicate : NamedNodePattern ,
pub object : GroundTermPattern ,
pub object : GroundTermPattern ,
}
}
impl fmt ::Debug for GroundTriplePattern {
impl GroundTriplePattern {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
write! (
write! ( f , "(triple " ) ? ;
f ,
self . subject . fmt_sse ( f ) ? ;
"(triple {:?} {:?} {:?})" ,
write! ( f , " " ) ? ;
self . subject , self . predicate , self . object
self . predicate . fmt_sse ( f ) ? ;
)
write! ( f , " " ) ? ;
self . object . fmt_sse ( f ) ? ;
write! ( f , ")" )
}
}
}
}
@ -1256,7 +1270,7 @@ impl TryFrom<TriplePattern> for GroundTriplePattern {
}
}
/// A [triple pattern](https://www.w3.org/TR/sparql11-query/#defn_TriplePattern) in a specific graph
/// A [triple pattern](https://www.w3.org/TR/sparql11-query/#defn_TriplePattern) in a specific graph
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub struct QuadPattern {
pub struct QuadPattern {
pub subject : TermPattern ,
pub subject : TermPattern ,
pub predicate : NamedNodePattern ,
pub predicate : NamedNodePattern ,
@ -1280,22 +1294,25 @@ impl QuadPattern {
}
}
}
}
impl fmt ::Debug for QuadPattern {
impl QuadPattern {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
if self . graph_name = = GraphNamePattern ::DefaultGraph {
if self . graph_name ! = GraphNamePattern ::DefaultGraph {
write! (
write! ( f , "(graph " ) ? ;
f ,
self . graph_name . fmt_sse ( f ) ? ;
"(triple {:?} {:?} {:?})" ,
write! ( f , " (" ) ? ;
self . subject , self . predicate , self . object
}
)
write! ( f , "(triple " ) ? ;
} else {
self . subject . fmt_sse ( f ) ? ;
write! (
write! ( f , " " ) ? ;
f ,
self . predicate . fmt_sse ( f ) ? ;
"(graph {:?} ((triple {:?} {:?} {:?})))" ,
write! ( f , " " ) ? ;
self . graph_name , self . subject , self . predicate , self . object
self . object . fmt_sse ( f ) ? ;
)
write! ( f , ")" ) ? ;
if self . graph_name ! = GraphNamePattern ::DefaultGraph {
write! ( f , "))" ) ? ;
}
}
Ok ( ( ) )
}
}
}
}
@ -1315,7 +1332,7 @@ impl fmt::Display for QuadPattern {
}
}
/// A [triple pattern](https://www.w3.org/TR/sparql11-query/#defn_TriplePattern) in a specific graph without blank nodes
/// A [triple pattern](https://www.w3.org/TR/sparql11-query/#defn_TriplePattern) in a specific graph without blank nodes
#[ derive(Eq, PartialEq, Clone, Hash) ]
#[ derive(Eq, PartialEq, Debug, Clone, Hash) ]
pub struct GroundQuadPattern {
pub struct GroundQuadPattern {
pub subject : GroundTermPattern ,
pub subject : GroundTermPattern ,
pub predicate : NamedNodePattern ,
pub predicate : NamedNodePattern ,
@ -1323,22 +1340,25 @@ pub struct GroundQuadPattern {
pub graph_name : GraphNamePattern ,
pub graph_name : GraphNamePattern ,
}
}
impl fmt ::Debug for GroundQuadPattern {
impl GroundQuadPattern {
#[ inline ]
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
fn fmt ( & self , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn fmt_sse ( & self , f : & mut impl Write ) -> fmt ::Result {
if self . graph_name = = GraphNamePattern ::DefaultGraph {
if self . graph_name ! = GraphNamePattern ::DefaultGraph {
write! (
write! ( f , "(graph " ) ? ;
f ,
self . graph_name . fmt_sse ( f ) ? ;
"(triple {:?} {:?} {:?})" ,
write! ( f , " (" ) ? ;
self . subject , self . predicate , self . object
}
)
write! ( f , "(triple " ) ? ;
} else {
self . subject . fmt_sse ( f ) ? ;
write! (
write! ( f , " " ) ? ;
f ,
self . predicate . fmt_sse ( f ) ? ;
"(graph {:?} ((triple {:?} {:?} {:?})))" ,
write! ( f , " " ) ? ;
self . graph_name , self . subject , self . predicate , self . object
self . object . fmt_sse ( f ) ? ;
)
write! ( f , ")" ) ? ;
if self . graph_name ! = GraphNamePattern ::DefaultGraph {
write! ( f , "))" ) ? ;
}
}
Ok ( ( ) )
}
}
}
}
@ -1372,7 +1392,7 @@ impl TryFrom<QuadPattern> for GroundQuadPattern {
}
}
#[ inline ]
#[ inline ]
pub ( crate ) fn print_quoted_str ( string : & str , f : & mut fmt ::Formatter < ' _ > ) -> fmt ::Result {
pub ( crate ) fn print_quoted_str ( string : & str , f : & mut impl Write ) -> fmt ::Result {
f . write_char ( '"' ) ? ;
f . write_char ( '"' ) ? ;
for c in string . chars ( ) {
for c in string . chars ( ) {
match c {
match c {