Crate linked_data

Source
Expand description

This library provides primitive traits to serialize and deserialize Linked-Data types. It is shipped with derive macros (using the derive feature) that can automatically implement those primitives for you.

§Example

use iref::IriBuf;
use static_iref::iri;

#[derive(linked_data::Serialize, linked_data::Deserialize)]
#[ld(prefix("ex" = "http://example.org/"))]
struct Foo {
  #[ld(id)]
  id: IriBuf,

  #[ld("ex:name")]
  name: String,

  #[ld("ex:email")]
  email: String
}

let value = Foo {
  id: iri!("http://example.org/JohnSmith").to_owned(),
  name: "John Smith".to_owned(),
  email: "john.smith@example.org".to_owned()
};

let quads = linked_data::to_quads(rdf_types::generator::Blank::new(), &value)
  .expect("RDF serialization failed");

for quad in quads {
  use rdf_types::RdfDisplay;
  println!("{} .", quad.rdf_display())
}

This should print the following:

<http://example.org/JohnSmith> <http://example.org/name> "John Smith" .
<http://example.org/JohnSmith> <http://example.org/email> "john.smith@example.org" .

Macros§

json_literal

Structs§

Anonymous
Anonymous lexical representation.
AnonymousBinding
AnonymousGraph
Ref

Enums§

Context
ContextIris
CowRdfLiteral
CowRdfTerm
CowRef
FromLinkedDataError
IntoQuadsError
RdfLiteral
RdfLiteralRef
ResourceInterpretation
Resource interpretation.
ResourceOrIriRef

Traits§

AsRdfLiteral
GraphVisitor
LinkedData
Linked-Data type.
LinkedDataDeserialize
LinkedDataDeserializePredicateObjects
LinkedDataDeserializeSubject
LinkedDataGraph
Serialize a Linked-Data graph.
LinkedDataPredicateObjects
Type representing the objects of an RDF subject’s predicate binding.
LinkedDataResource
Type that can have an interpretation.
LinkedDataResourceRef
Type that can have an interpretation bound to the given lifetime.
LinkedDataSubject
Serialize a Linked-Data node.
PredicateObjectsVisitor
RdfLiteralType
RdfLiteralValue
SubjectVisitor
Visitor
RDF dataset visitor.

Functions§

to_interpreted_graph_quads
to_interpreted_quads
to_interpreted_subject_quads
to_lexical_quads
to_lexical_quads_with
to_lexical_subject_quads
to_lexical_subject_quads_with
to_quads
to_quads_with

Type Aliases§

InterpretedQuad
RdfId
RdfIdRef
RdfQuad
RdfTerm
RdfTermRef

Derive Macros§

Deserialize
Serialize