pub enum QuotedTripleSurface {
RdfStar,
Rdf12,
}Expand description
Which surface a << … >> in Turtle/TriG input is read as — the input
half of rete export --quoted-triple-syntax, same vocabulary, same two
values.
The flag exists because the two standards give one piece of syntax two meanings, and no amount of looking at the bytes can tell them apart:
| written | under RdfStar | under Rdf12 |
|---|---|---|
<< s p o >> | a quoted triple, one term | a reifier: _:r rdf:reifies <<( s p o )>>, plus a blank node standing where it was |
<<( s p o )>> | a syntax error | a triple term, object position only |
{| … |} | a syntax error | an annotation on the statement before it |
One file, two readings, two different graphs — see the round-trip matrix in
crates/rete-cli/tests/quoted_triple_surfaces.rs, which asserts both.
<<( s p o )>> is unambiguous: it is RDF 1.2’s and nothing else’s. That
asymmetry is why RdfStar is the default. Reading an
RDF-star file as RDF 1.2 silently yields a different graph; reading an
RDF 1.2 file as RDF-star is a hard parse error that names the flag. Only one
of the two mistakes is survivable, so the default is the one that makes the
other mistake loud.
N-Triples and N-Quads ignore this entirely. Their reader is rete’s own
(take_term), it has accepted both << s p o >> and <<( s p o )>> since
#262, and RDF 1.2 N-Triples has no reifier syntax for << … >> to be — so
there is no ambiguity to resolve and nothing to choose. The same goes for
RDF/XML.
Whichever surface reads the file, what gets stored is the same canonical
token <<s p o>>. rete’s term model is a superset of both: a triple term is
a term, and RDF 1.2 reification is ordinary RDF — a blank node, a predicate
and a term — which rete already stored before this flag existed.
Variants§
RdfStar
<< s p o >> is a quoted triple (RDF-star), in subject or object
position — rete’s own storage token. The default, and byte-for-byte the
behaviour every rete release before this flag had.
Rdf12
<<( s p o )>> is a triple term and << s p o >> is a reifier
(RDF 1.2), with {| … |} annotations read too.
Implementations§
Source§impl QuotedTripleSurface
impl QuotedTripleSurface
Sourcepub fn parse(s: &str) -> Option<QuotedTripleSurface>
pub fn parse(s: &str) -> Option<QuotedTripleSurface>
Parse the --quoted-triple-syntax value, None for anything else.
Shared by rete build, rete validate and rete export so the flag
cannot come to mean two things in two directions.
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
The flag spelling of this surface — the inverse of Self::parse.
Trait Implementations§
Source§impl Clone for QuotedTripleSurface
impl Clone for QuotedTripleSurface
Source§fn clone(&self) -> QuotedTripleSurface
fn clone(&self) -> QuotedTripleSurface
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more