1pub mod braille;
10
11pub mod graph {
12 use std::{char, error, fmt, result};
13
14 #[derive(Debug)]
15 pub struct ParseGraphError;
16
17 pub type Result<T> = result::Result<T, ParseGraphError>;
18
19 impl error::Error for ParseGraphError {
20 fn description(&self) -> &str { "failed to parse graph" }
21 }
22
23 impl fmt::Display for ParseGraphError {
24 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
25 write!(f, "Parse error: failed to parse graph")
26 }
27 }
28
29 pub fn graph_to_strings(input: Vec<Vec<u32>>) -> Result<Vec<String>> {
30 let mut output = Vec::new();
31
32 for (index,line) in input.iter().enumerate() {
33 let mut string = String::new();
34
35 for block in line {
36 string.push(try!(char::from_u32(*block).ok_or(ParseGraphError)))
37 };
38
39 output.insert(index,string)
40 };
41
42 Ok(output)
43 }
44}