-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dfe5473
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |