rdf

    Pure four-target RDF 1.1 dataset, SKOS/SHACL projection, and Turtle/JSON-LD codecs

    rdf
    skos
    shacl
    turtle
    json-ld
    Download zip
    Author
    Version
    0.7.0
    License
    Apache-2.0
    Last updated
    12 hours ago
    Downloads
    11

    #moonrockz/rdf

    Pure, zero-I/O, four-target (wasm, wasm-gc, js, native) RDF 1.1 dataset, SKOS/SHACL domain projection, and Turtle / JSON-LD codecs for Mission Control.

    BlankNodeIdError

    pub suberror BlankNodeIdError {
    InvalidBlankNodeId(input~ : String)
    } derive(Eq,
    Debug
    )

    Parse error for BlankNodeId.

    BlankNodeIdError::equal

    automatically derived

    BlankNodeIdError::not_equal

    fn BlankNodeIdError::not_equal(x : BlankNodeIdError, y : BlankNodeIdError) -> Bool
    automatically derived

    BlankNodeIdError::to_repr

    automatically derived

    IriError

    pub suberror IriError {
    InvalidIri(input~ : String, rule~ : IriRule)
    } derive(Eq,
    Debug
    )

    Parse error for Iri.

    IriError::equal

    fn IriError::equal(IriError, IriError) -> Bool
    automatically derived

    IriError::not_equal

    fn IriError::not_equal(x : IriError, y : IriError) -> Bool
    automatically derived

    IriError::to_repr

    automatically derived

    JsonLdParseError

    pub suberror JsonLdParseError {
    InvalidJson(detail~ : String)
    InvalidStructure(detail~ : String)
    InvalidTerm(detail~ : String)
    } derive(Eq,
    Debug
    )

    Typed parse error for JSON-LD documents.

    JsonLdParseError::equal

    automatically derived

    JsonLdParseError::not_equal

    fn JsonLdParseError::not_equal(x : JsonLdParseError, y : JsonLdParseError) -> Bool
    automatically derived

    JsonLdParseError::to_repr

    automatically derived

    LangTagError

    pub suberror LangTagError {
    InvalidLangTag(input~ : String)
    } derive(Eq,
    Debug
    )

    Parse error for LangTag.

    LangTagError::equal

    automatically derived

    LangTagError::not_equal

    fn LangTagError::not_equal(x : LangTagError, y : LangTagError) -> Bool
    automatically derived

    LangTagError::to_repr

    automatically derived

    TurtleParseError

    pub suberror TurtleParseError {
    UnexpectedEnd(line~ : Int, expected~ : String)
    UnexpectedToken(line~ : Int, found~ : String, expected~ : String)
    UndeclaredPrefix(line~ : Int, prefix~ : String)
    InvalidTerm(line~ : Int, detail~ : String)
    } derive(Eq,
    Debug
    )

    Typed parse error for Turtle documents with 1-based line number.

    TurtleParseError::equal

    automatically derived

    TurtleParseError::not_equal

    fn TurtleParseError::not_equal(x : TurtleParseError, y : TurtleParseError) -> Bool
    automatically derived

    TurtleParseError::to_repr

    automatically derived

    BlankNodeId

    pub struct BlankNodeId {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    Validated RDF blank node label (without the leading _: prefix).
    impl Show for BlankNodeId

    BlankNodeId::BlankNodeId

    fn BlankNodeId::BlankNodeId(raw : String) -> BlankNodeId raise BlankNodeIdError

    Parses a validated blank node label ([A-Za-z0-9_.-]+, not starting or ending with .).

    BlankNodeId::as_str

    fn BlankNodeId::as_str(self : BlankNodeId) -> String

    Returns the blank node label without _:.

    BlankNodeId::compare

    fn BlankNodeId::compare(BlankNodeId, BlankNodeId) -> Int
    automatically derived

    BlankNodeId::equal

    fn BlankNodeId::equal(BlankNodeId, BlankNodeId) -> Bool
    automatically derived

    BlankNodeId::hash_combine

    fn BlankNodeId::hash_combine(BlankNodeId, Hasher) -> Unit
    automatically derived

    BlankNodeId::not_equal

    fn BlankNodeId::not_equal(x : BlankNodeId, y : BlankNodeId) -> Bool
    automatically derived

    BlankNodeId::to_repr

    automatically derived

    Dataset

    pub struct Dataset {
    // private fields
    } derive(Eq,
    Debug
    )

    Immutable RDF 1.1 dataset with mathematical set semantics over Quads.

    Dataset::Dataset

    fn Dataset::Dataset(quads : Array[Quad]) -> Dataset

    Builds a deduplicated, canonically ordered Dataset from quads.

    Dataset::empty

    fn Dataset::empty() -> Dataset

    Empty dataset containing zero quads.

    Dataset::equal

    fn Dataset::equal(Dataset, Dataset) -> Bool
    automatically derived

    Dataset::from_triples

    fn Dataset::from_triples(triples : Array[Triple], graph? : GraphName) -> Dataset

    Builds a Dataset placing triples into graph (defaulting to DefaultGraph).

    Dataset::graph_names

    fn Dataset::graph_names(self : Dataset) -> ReadOnlyArray[GraphName]

    Distinct graph names present in the dataset in canonical order.

    Dataset::is_empty

    fn Dataset::is_empty(self : Dataset) -> Bool

    Whether the dataset contains zero quads.

    Dataset::length

    fn Dataset::length(self : Dataset) -> Int

    Number of unique quads in the dataset.

    Dataset::match_quads

    fn Dataset::match_quads(self : Dataset, subject? : Subject?, predicate? : Iri?, object? : ObjectTerm?, graph? : GraphName?) -> ReadOnlyArray[Quad]

    Filters quads by optional subject, predicate, object, and graph criteria.

    Dataset::merge

    fn Dataset::merge(self : Dataset, other : Dataset) -> Dataset

    Merges two datasets with set-union semantics (commutative, associative, idempotent).

    Dataset::not_equal

    fn Dataset::not_equal(x : Dataset, y : Dataset) -> Bool
    automatically derived

    Dataset::quads

    fn Dataset::quads(self : Dataset) -> ReadOnlyArray[Quad]

    All quads in canonical order.

    Dataset::to_repr

    automatically derived

    Dataset::triples_in

    fn Dataset::triples_in(self : Dataset, graph : GraphName) -> ReadOnlyArray[Triple]

    All triples belonging to graph in canonical order.

    Dataset::with_quad

    fn Dataset::with_quad(self : Dataset, quad : Quad) -> Dataset

    Returns a new dataset containing quad.

    GraphName

    pub(all) enum GraphName {
    DefaultGraph
    NamedGraph(Iri)
    } derive(Compare, Eq, Hash,
    Debug
    )

    Target graph inside an RDF dataset (DefaultGraph or NamedGraph(Iri)).

    GraphName::compare

    fn GraphName::compare(GraphName, GraphName) -> Int
    automatically derived

    GraphName::equal

    fn GraphName::equal(GraphName, GraphName) -> Bool
    automatically derived

    GraphName::hash_combine

    fn GraphName::hash_combine(GraphName, Hasher) -> Unit
    automatically derived

    GraphName::not_equal

    fn GraphName::not_equal(x : GraphName, y : GraphName) -> Bool
    automatically derived

    GraphName::to_repr

    automatically derived

    Iri

    pub struct Iri {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    Validated absolute IRI (scheme:rest with no whitespace, control chars, or forbidden RDF delimiter characters).
    impl Show for Iri

    Iri::Iri

    fn Iri::Iri(raw : String) -> Iri raise IriError

    Parses a validated absolute IRI.

    Iri::as_str

    fn Iri::as_str(self : Iri) -> String

    Returns the IRI text.

    Iri::compare

    fn Iri::compare(Iri, Iri) -> Int
    automatically derived

    Iri::equal

    fn Iri::equal(Iri, Iri) -> Bool
    automatically derived

    Iri::hash_combine

    fn Iri::hash_combine(Iri, Hasher) -> Unit
    automatically derived

    Iri::not_equal

    fn Iri::not_equal(x : Iri, y : Iri) -> Bool
    automatically derived

    Iri::owl_deprecated

    fn Iri::owl_deprecated() -> Iri

    Standard owl:deprecated IRI.

    Iri::rdf_type

    fn Iri::rdf_type() -> Iri

    Standard rdf:type IRI.

    Iri::sh_datatype

    fn Iri::sh_datatype() -> Iri

    Standard sh:datatype IRI.

    Iri::sh_max_length

    fn Iri::sh_max_length() -> Iri

    Standard sh:maxLength IRI.

    Iri::sh_message

    fn Iri::sh_message() -> Iri

    Standard sh:message IRI.

    Iri::sh_min_length

    fn Iri::sh_min_length() -> Iri

    Standard sh:minLength IRI.

    Iri::sh_pattern

    fn Iri::sh_pattern() -> Iri

    Standard sh:pattern IRI.

    Iri::skos_alt_label

    fn Iri::skos_alt_label() -> Iri

    Standard skos:altLabel IRI.

    Iri::skos_broader

    fn Iri::skos_broader() -> Iri

    Standard skos:broader IRI.

    Iri::skos_concept

    fn Iri::skos_concept() -> Iri

    Standard skos:Concept IRI.

    Iri::skos_definition

    fn Iri::skos_definition() -> Iri

    Standard skos:definition IRI.

    Iri::skos_hidden_label

    fn Iri::skos_hidden_label() -> Iri

    Standard skos:hiddenLabel IRI.

    Iri::skos_narrower

    fn Iri::skos_narrower() -> Iri

    Standard skos:narrower IRI.

    Iri::skos_pref_label

    fn Iri::skos_pref_label() -> Iri

    Standard skos:prefLabel IRI.
    fn Iri::skos_related() -> Iri

    Standard skos:related IRI.

    Iri::to_repr

    automatically derived

    Iri::xsd_boolean

    fn Iri::xsd_boolean() -> Iri

    Standard xsd:boolean IRI.

    Iri::xsd_integer

    fn Iri::xsd_integer() -> Iri

    Standard xsd:integer IRI.

    Iri::xsd_string

    fn Iri::xsd_string() -> Iri

    Standard xsd:string IRI.

    IriRule

    pub(all) enum IriRule {
    Empty
    MissingScheme
    InvalidScheme
    IllegalCharacter
    } derive(Eq,
    Debug
    )

    Reason why an Iri failed RFC 3987 / RDF 1.1 validation.

    IriRule::equal

    fn IriRule::equal(IriRule, IriRule) -> Bool
    automatically derived

    IriRule::not_equal

    fn IriRule::not_equal(x : IriRule, y : IriRule) -> Bool
    automatically derived

    IriRule::to_repr

    automatically derived

    LangTag

    pub struct LangTag {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    Validated lowercase BCP-47 language tag (for example "en" or "en-us").
    impl Show for LangTag

    LangTag::LangTag

    fn LangTag::LangTag(raw : String) -> LangTag raise LangTagError

    Parses and lowercases a BCP-47 language tag.

    LangTag::as_str

    fn LangTag::as_str(self : LangTag) -> String

    Returns the normalized lowercase language tag.

    LangTag::compare

    fn LangTag::compare(LangTag, LangTag) -> Int
    automatically derived

    LangTag::en

    fn LangTag::en() -> LangTag

    Canonical English language tag ("en").

    LangTag::equal

    fn LangTag::equal(LangTag, LangTag) -> Bool
    automatically derived

    LangTag::hash_combine

    fn LangTag::hash_combine(LangTag, Hasher) -> Unit
    automatically derived

    LangTag::not_equal

    fn LangTag::not_equal(x : LangTag, y : LangTag) -> Bool
    automatically derived

    LangTag::to_repr

    automatically derived

    Literal

    pub(all) enum Literal {
    Plain(String)
    LangString(value~ : String, lang~ : LangTag)
    Typed(value~ : String, datatype~ : Iri)
    } derive(Compare, Eq, Hash,
    Debug
    )

    An RDF 1.1 literal value.

    Literal::compare

    fn Literal::compare(Literal, Literal) -> Int
    automatically derived

    Literal::equal

    fn Literal::equal(Literal, Literal) -> Bool
    automatically derived

    Literal::hash_combine

    fn Literal::hash_combine(Literal, Hasher) -> Unit
    automatically derived

    Literal::lexical

    fn Literal::lexical(self : Literal) -> String

    Extracts the lexical string of any literal variant.

    Literal::not_equal

    fn Literal::not_equal(x : Literal, y : Literal) -> Bool
    automatically derived

    Literal::to_repr

    automatically derived

    ObjectTerm

    pub(all) enum ObjectTerm {
    IriObject(Iri)
    BlankObject(BlankNodeId)
    LiteralObject(Literal)
    } derive(Compare, Eq, Hash,
    Debug
    )

    RDF triple object (Iri, BlankNodeId, or Literal).

    ObjectTerm::compare

    fn ObjectTerm::compare(ObjectTerm, ObjectTerm) -> Int
    automatically derived

    ObjectTerm::equal

    fn ObjectTerm::equal(ObjectTerm, ObjectTerm) -> Bool
    automatically derived

    ObjectTerm::hash_combine

    fn ObjectTerm::hash_combine(ObjectTerm, Hasher) -> Unit
    automatically derived

    ObjectTerm::not_equal

    fn ObjectTerm::not_equal(x : ObjectTerm, y : ObjectTerm) -> Bool
    automatically derived

    ObjectTerm::to_repr

    automatically derived

    Quad

    pub struct Quad {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    An RDF 1.1 quad (graph, subject, predicate, object).

    Quad::Quad

    fn Quad::Quad(graph? : GraphName, subject~ : Subject, predicate~ : Iri, object~ : ObjectTerm) -> Quad

    Constructs an immutable Quad.

    Quad::compare

    fn Quad::compare(Quad, Quad) -> Int
    automatically derived

    Quad::equal

    fn Quad::equal(Quad, Quad) -> Bool
    automatically derived

    Quad::graph

    fn Quad::graph(self : Quad) -> GraphName

    Owning graph name.

    Quad::hash_combine

    fn Quad::hash_combine(Quad, Hasher) -> Unit
    automatically derived

    Quad::not_equal

    fn Quad::not_equal(x : Quad, y : Quad) -> Bool
    automatically derived

    Quad::object

    fn Quad::object(self : Quad) -> ObjectTerm

    Quad object.

    Quad::predicate

    fn Quad::predicate(self : Quad) -> Iri

    Quad predicate.

    Quad::subject

    fn Quad::subject(self : Quad) -> Subject

    Quad subject.

    Quad::to_repr

    automatically derived

    Quad::triple

    fn Quad::triple(self : Quad) -> Triple

    Underlying triple.

    ShaclConstraint

    pub(all) enum ShaclConstraint {
    MinLength(Int)
    MaxLength(Int)
    Pattern(String)
    Datatype(Iri)
    Note(String)
    } derive(Compare, Eq,
    Debug
    )

    A SHACL-derived validation constraint attached to a SKOS concept.

    ShaclConstraint::compare

    automatically derived

    ShaclConstraint::equal

    automatically derived

    ShaclConstraint::not_equal

    fn ShaclConstraint::not_equal(x : ShaclConstraint, y : ShaclConstraint) -> Bool
    automatically derived

    ShaclConstraint::summary

    fn ShaclConstraint::summary(self : ShaclConstraint) -> String

    Human-readable one-line summary of a ShaclConstraint.

    ShaclConstraint::to_repr

    automatically derived

    SkosConcept

    pub struct SkosConcept {
    // private fields
    } derive(Eq,
    Debug
    )

    Immutable SKOS concept projected from an RDF graph (named or default).

    SkosConcept::SkosConcept

    fn SkosConcept::SkosConcept(iri~ : Iri, graph? : GraphName, pref_label~ : String, definition? : String, alt_labels? : Array[String], hidden_labels? : Array[String], deprecated? : Bool, broader? : Array[Iri], narrower? : Array[Iri], related? : Array[Iri], constraints? : Array[ShaclConstraint]) -> SkosConcept

    Constructs an immutable SkosConcept with canonically sorted relation and label collections.

    SkosConcept::alt_labels

    fn SkosConcept::alt_labels(self : SkosConcept) -> ReadOnlyArray[String]

    SkosConcept::broader

    fn SkosConcept::broader(self : SkosConcept) -> ReadOnlyArray[Iri]

    SkosConcept::constraints

    fn SkosConcept::constraints(self : SkosConcept) -> ReadOnlyArray[ShaclConstraint]

    SkosConcept::definition

    fn SkosConcept::definition(self : SkosConcept) -> String

    SkosConcept::deprecated

    fn SkosConcept::deprecated(self : SkosConcept) -> Bool

    SkosConcept::equal

    fn SkosConcept::equal(SkosConcept, SkosConcept) -> Bool
    automatically derived

    SkosConcept::graph

    fn SkosConcept::graph(self : SkosConcept) -> GraphName

    SkosConcept::hidden_labels

    fn SkosConcept::hidden_labels(self : SkosConcept) -> ReadOnlyArray[String]

    SkosConcept::iri

    fn SkosConcept::iri(self : SkosConcept) -> Iri

    SkosConcept::narrower

    fn SkosConcept::narrower(self : SkosConcept) -> ReadOnlyArray[Iri]

    SkosConcept::not_equal

    fn SkosConcept::not_equal(x : SkosConcept, y : SkosConcept) -> Bool
    automatically derived

    SkosConcept::pref_label

    fn SkosConcept::pref_label(self : SkosConcept) -> String

    SkosConcept::related

    fn SkosConcept::related(self : SkosConcept) -> ReadOnlyArray[Iri]

    SkosConcept::to_repr

    automatically derived

    Subject

    pub(all) enum Subject {
    IriSubject(Iri)
    BlankSubject(BlankNodeId)
    } derive(Compare, Eq, Hash,
    Debug
    )

    RDF triple subject (Iri or BlankNodeId).

    Subject::compare

    fn Subject::compare(Subject, Subject) -> Int
    automatically derived

    Subject::equal

    fn Subject::equal(Subject, Subject) -> Bool
    automatically derived

    Subject::hash_combine

    fn Subject::hash_combine(Subject, Hasher) -> Unit
    automatically derived

    Subject::not_equal

    fn Subject::not_equal(x : Subject, y : Subject) -> Bool
    automatically derived

    Subject::to_repr

    automatically derived

    Triple

    pub struct Triple {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    An RDF 1.1 triple (subject, predicate, object).

    Triple::Triple

    fn Triple::Triple(subject~ : Subject, predicate~ : Iri, object~ : ObjectTerm) -> Triple

    Constructs an immutable Triple.

    Triple::compare

    fn Triple::compare(Triple, Triple) -> Int
    automatically derived

    Triple::equal

    fn Triple::equal(Triple, Triple) -> Bool
    automatically derived

    Triple::hash_combine

    fn Triple::hash_combine(Triple, Hasher) -> Unit
    automatically derived

    Triple::not_equal

    fn Triple::not_equal(x : Triple, y : Triple) -> Bool
    automatically derived

    Triple::object

    fn Triple::object(self : Triple) -> ObjectTerm

    Triple object term.

    Triple::predicate

    fn Triple::predicate(self : Triple) -> Iri

    Triple predicate IRI.

    Triple::subject

    fn Triple::subject(self : Triple) -> Subject

    Triple subject.

    Triple::to_repr

    automatically derived

    concept_to_quads

    fn concept_to_quads(concept : SkosConcept) -> Array[Quad]

    Projects a SkosConcept into canonical RDF quads inside its owning graph.

    extract_skos_concepts

    fn extract_skos_concepts(dataset : Dataset) -> ReadOnlyArray[SkosConcept]

    Extracts all SkosConcept values from every graph in dataset, ordered deterministically by (graph, iri).

    parse_jsonld

    fn parse_jsonld(input : String, graph? : GraphName) -> Dataset raise JsonLdParseError

    Parses a JSON-LD 1.1 document into an immutable Dataset in graph.

    parse_turtle

    fn parse_turtle(input : String, graph? : GraphName) -> Dataset raise TurtleParseError

    Parses a Turtle 1.1 document into an immutable Dataset in graph.

    serialize_jsonld

    fn serialize_jsonld(triples : ReadOnlyArray[Triple], prefixes? : Array[(String, Iri)]) -> String

    Serializes RDF triples into pretty-printed JSON-LD 1.1 with @context and @graph (or a single top-level node when exactly one subject is present).

    serialize_turtle

    fn serialize_turtle(triples : ReadOnlyArray[Triple], prefixes? : Array[(String, Iri)]) -> String

    Serializes RDF triples to readable, deterministic Turtle 1.1 grouped by subject and predicate.

    standard_prefixes

    fn standard_prefixes() -> Array[(String, Iri)]

    Standard default namespace prefixes for SKOS, SHACL, OWL, RDF, and XSD.