use oxrdf::Graph;
use oxttl::{TurtleParseError, TurtleParser};

/// parses a turtle string into a graph
pub fn parse_ttl_into_graph(ttl: &str) -> Result<Graph, TurtleParseError> {
    let ttl_parser = TurtleParser::new().for_reader(ttl.as_bytes());
    let mut graph = Graph::new();

    for maybe_triple in ttl_parser {
        match maybe_triple {
            Ok(triple) => graph.insert(&triple),
            Err(e) => return Err(e),
        };
    }

    Ok(graph)
}
