Skip to content

Commit

Permalink
Starting point
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 3, 2014
0 parents commit dfe5473
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
57 changes: 57 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]

name = "rust-ldp-client"
version = "0.0.1"
authors = ["justin <justin@curationexperts.com>"]

[dependencies.curl]
git = "https://github.com/carllerche/curl-rust"
71 changes: 71 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#![feature(phase)]
extern crate regex;
#[phase(plugin)] extern crate regex_macros;
extern crate curl;
use curl::http;
use std::str;


fn main() {
let resp = http::handle()
.get("http://localhost:8983/fedora/rest")
.exec().unwrap();

let body_string = match str::from_utf8(resp.get_body()) {
Some(e) => e,
None => panic!("Invalid UTF-8 sequence"),
};

turtle::parse(body_string);

println!("code={}; headers={}; body={}",
resp.get_code(), resp.get_headers(), body_string);
}


mod rdf {
pub struct URI(pub String);

pub enum URIorLiteral {
URI(URI),
Literal(String)
}

pub struct Statement {
pub subject: URI,
pub predicate: URI,
pub object: URIorLiteral,
}

pub struct Graph {
pub statements: Vec<Statement>
}

impl Graph {
pub fn new() -> Graph {
Graph { statements: vec![] }
}
}
}


mod turtle {
use rdf;

pub fn parse(raw: &str) -> rdf::Graph {
let mut g = rdf::Graph::new();
let lines: Vec<&str> = raw.split('\n').collect();


for line in lines.iter() {
let matched = regex!(r"\A<[^>]+>").is_match(*line);
if matched {
println!("Found a line that has data:\n {}", line);
}
}
rdf::URIorLiteral::URI(rdf::URI("http://baz".to_string()));

g.statements = vec![rdf::Statement { subject: rdf::URI("http://foo".to_string()), predicate: rdf::URI("http://bar".to_string()), object: rdf::URIorLiteral::URI(rdf::URI("http://baz".to_string())) }];
return g;
}
}

0 comments on commit dfe5473

Please sign in to comment.