1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//! # rdf-rs
//!
//! A crate for the Resource Description Framework (RDF) and SPARQL.
//!
//! ---
//!
//! This crate enables to parse certain RDF formats to an RDF graph, as well as writing
//! an RDF graph as RDF syntax.
//!
//! Currently supported RDF formats are:
//!
//! * Turtle
//! * N-Triples
//!
//!
//! ## Usage
//!
//! Each module contains a comprehensive documentation with usage examples.
//! In the following, only the basic functionality is introduced.
//!
//! RDF triples can be stored and represented in a graph.
//!
//! ```
//! use rdf::graph::Graph;
//! use rdf::uri::Uri;
//! use rdf::triple::Triple;
//!
//! let mut graph = Graph::new(None);
//!
//! let subject = graph.create_blank_node();
//! let predicate = graph.create_uri_node(&Uri::new("http://example.org/show/localName".to_string()));
//! let object = graph.create_blank_node();
//! let triple = Triple::new(&subject, &predicate, &object);
//!
//! graph.add_triple(&triple);
//! ```
//!
//! RDF graphs can be serialized to a supported format.
//!
//! ```
//! use rdf::writer::n_triples_writer::NTriplesWriter;
//! use rdf::writer::rdf_writer::RdfWriter;
//! use rdf::graph::Graph;
//! use rdf::uri::Uri;
//! use rdf::triple::Triple;
//!
//! let writer = NTriplesWriter::new();
//!
//! let mut graph = Graph::new(None);
//! let subject = graph.create_blank_node();
//! let predicate = graph.create_uri_node(&Uri::new("http://example.org/show/localName".to_string()));
//! let object = graph.create_blank_node();
//! let triple = Triple::new(&subject, &predicate, &object);
//!
//! graph.add_triple(&triple);
//!
//! assert_eq!(writer.write_to_string(&graph).unwrap(),
//!            "_:auto0 <http://example.org/show/localName> _:auto1 .\n".to_string());
//! ```
//!
//! RDF syntax can also be parsed and transformed into an RDF graph.
//!
//! ```
//! use rdf::reader::turtle_parser::TurtleParser;
//! use rdf::reader::rdf_parser::RdfParser;
//! use rdf::uri::Uri;
//!
//! let input = "@base <http://example.org/> .
//! @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
//! @prefix foaf: <http://xmlns.com/foaf/0.1/> .
//!
//! <http://www.w3.org/2001/sw/RDFCore/ntriples/> rdf:type foaf:Document ;
//!     <http://purl.org/dc/terms/title> \"N-Triples\"@en-US ;
//!     foaf:maker _:art .";
//!
//! let mut reader = TurtleParser::from_string(input.to_string());
//!
//! match reader.decode() {
//!   Ok(graph) => {
//!     assert_eq!(graph.count(), 3);
//!     assert_eq!(graph.namespaces().len(), 2);
//!     assert_eq!(graph.base_uri(), &Some(Uri::new("http://example.org/".to_string())))
//!   },
//!   Err(_) => assert!(false)
//! }
//! ```

use std::result;

pub mod uri;
pub mod namespace;
pub mod node;
pub mod triple;
pub mod graph;
pub mod error;

pub type Result<T> = result::Result<T, error::Error>;

pub mod writer {
    pub mod formatter {
        pub mod rdf_formatter;
        pub mod turtle_formatter;
        pub mod n_triples_formatter;
    }

    pub mod rdf_writer;
    pub mod turtle_writer;
    pub mod n_triples_writer;
}

pub mod reader {
    pub mod lexer {
        pub mod token;
        pub mod rdf_lexer;
        pub mod n_triples_lexer;
        pub mod turtle_lexer;
    }

    pub mod rdf_parser;
    pub mod n_triples_parser;
    pub mod turtle_parser;
    pub mod input_reader;
}

pub mod specs {
    pub mod xml_specs;
    pub mod turtle_specs;
    pub mod rdf_syntax_specs;
}

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {}
}