diff --git a/src/main.rs b/src/main.rs index ab8dcb4..6a7bfba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ async fn main() -> io::Result<()> { })); let graph = populate_graph(); - let app = en::router::new(&graph); + let router = en::router::new(&graph); let listener = tokio::net::TcpListener::bind(&address).await.map_err(|e| { @@ -42,7 +42,7 @@ async fn main() -> io::Result<()> { .unwrap_or("".to_string()) ); - axum::serve(listener, app).await.map_err(|e| { + axum::serve(listener, router).await.map_err(|e| { log!("Failed to serve application: {e:#?}"); io::Error::other(e) })?; diff --git a/src/router.rs b/src/router.rs index 351b18d..735ca6b 100644 --- a/src/router.rs +++ b/src/router.rs @@ -41,13 +41,13 @@ pub fn new(graph: &Graph) -> Router { if graph.meta.config.raw_json { router = router.route( "/graph/json", - get(|| handlers::fixed::serial(&Format::Json)), + get(|| handlers::fixed::serial(&Format::JSON)), ); } if graph.meta.config.raw_toml { router = router.route( "/graph/toml", - get(|| handlers::fixed::serial(&Format::Toml)), + get(|| handlers::fixed::serial(&Format::TOML)), ); } } diff --git a/src/syntax/serial.rs b/src/syntax/serial.rs index 10abf45..5fb87cf 100644 --- a/src/syntax/serial.rs +++ b/src/syntax/serial.rs @@ -11,7 +11,7 @@ pub fn populate_graph() -> Graph { Ok(s) => s, Err(e) => format!("Error: {e}"), }; - let graph = deserialize_graph(&Format::Toml, &toml_source); + let graph = deserialize_graph(&Format::TOML, &toml_source); let nodes = modulate_nodes(&graph.nodes); @@ -107,17 +107,17 @@ fn make_incoming(nodes: &HashMap) -> HashMap> { } pub enum Format { - Toml, - Json, + TOML, + JSON, } pub fn serialize_graph(out_format: &Format, graph: &Graph) -> String { match *out_format { - Format::Toml => match toml::to_string(graph) { + Format::TOML => match toml::to_string(graph) { Ok(s) => s, Err(e) => e.to_string(), }, - Format::Json => match serde_json::to_string(graph) { + Format::JSON => match serde_json::to_string(graph) { Ok(s) => s, Err(e) => e.to_string(), }, @@ -126,11 +126,11 @@ pub fn serialize_graph(out_format: &Format, graph: &Graph) -> String { pub fn deserialize_graph(in_format: &Format, serial: &str) -> Graph { match *in_format { - Format::Toml => match toml::from_str(serial) { + Format::TOML => match toml::from_str(serial) { Ok(g) => g, Err(error) => Graph::new(Some(error.to_string())), }, - Format::Json => match serde_json::from_str(serial) { + Format::JSON => match serde_json::from_str(serial) { Ok(g) => g, Err(error) => Graph::new(Some(error.to_string())), }, diff --git a/src/types.rs b/src/types.rs index 8d0e771..809d78d 100644 --- a/src/types.rs +++ b/src/types.rs @@ -112,7 +112,7 @@ fn mk8() -> u16 { } impl Graph { - pub fn new(message: Option) -> Graph { + pub fn new(message: Option<&str>) -> Graph { Graph { nodes: HashMap::new(), root_node: "VoidNode".to_string(), @@ -141,7 +141,7 @@ impl Graph { content_language: String::new(), }, version: (0, 1, 0), - messages: message.map_or(vec![], |m| vec![m]), + messages: message.map_or(vec![], |m| vec![m.to_string()]), }, } } diff --git a/static/graph.toml b/static/graph.toml index 76b2ce3..f66957c 100644 --- a/static/graph.toml +++ b/static/graph.toml @@ -397,5 +397,5 @@ Syntax|syntax| content_language = "en" footer_credits = false footer_text = """ -made by jutty|https://jutty.dev • acknowledgements|Acknowledgments • |source code|https://codeberg.org/jutty/en +made by jutty|https://jutty.dev • acknowledgments|Acknowledgments • |source code|https://codeberg.org/jutty/en """ diff --git a/tests/smoke.rs b/tests/smoke.rs deleted file mode 100644 index 7b5e39d..0000000 --- a/tests/smoke.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[test] -fn add() { - let e = 0; - let n = 0; - assert_eq!(e, n); -}