From 62fe54b807248f9b9bdce12fdf491958e2efc02f Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sun, 20 Aug 2023 18:34:22 -0700 Subject: [PATCH] cargo fmt --- dyesub-tool/src/main.rs | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/dyesub-tool/src/main.rs b/dyesub-tool/src/main.rs index 890fc29..f6fcd99 100644 --- a/dyesub-tool/src/main.rs +++ b/dyesub-tool/src/main.rs @@ -3,11 +3,11 @@ mod render; pub mod svg; -use leptos::{*, ev::SubmitEvent, html::Input}; +use derive_more::From; +use leptos::{ev::SubmitEvent, html::Input, *}; +use strum_macros::IntoStaticStr; use wasm_bindgen::{JsCast, JsValue}; use web_sys::File; -use strum_macros::IntoStaticStr; -use derive_more::From; #[derive(Clone)] struct ResultMessageData { @@ -55,7 +55,7 @@ enum ReadKleError { #[strum(serialize = "Failed to parse file to string")] ParseToString, #[strum(serialize = "Failed to parse KLE JSON")] - Serde(serde_json::Error) + Serde(serde_json::Error), } impl ToString for ReadKleError { @@ -71,12 +71,17 @@ impl ToString for ReadKleError { } } -async fn read_kle_from_file(file: &ReadSignal>) -> Result { +async fn read_kle_from_file( + file: &ReadSignal>, +) -> Result { let file = match file() { Some(file) => file, None => return Err(ReadKleError::NoFile), }; - let file_contents = match wasm_bindgen_futures::JsFuture::from(file.text()).await?.as_string() { + let file_contents = match wasm_bindgen_futures::JsFuture::from(file.text()) + .await? + .as_string() + { Some(contents) => contents, None => return Err(ReadKleError::ParseToString), }; @@ -85,7 +90,10 @@ async fn read_kle_from_file(file: &ReadSignal>) -> Result>) -> impl IntoView { +fn KeyboardFromFile( + cx: Scope, + set_keyboard: WriteSignal>, +) -> impl IntoView { let file_input = create_node_ref::(cx); let (file, set_file) = create_signal(cx, Option::::None); let (result_message, set_result_message) = create_signal(cx, Option::::None); @@ -98,20 +106,22 @@ fn KeyboardFromFile(cx: Scope, set_keyboard: WriteSignal{&keyboard.metadata.name}" successfully!" - }.into_view(cx), + } + .into_view(cx), colorway: Colorway::Ok, })); set_keyboard(Some(keyboard)); - }, + } Err(err) => set_result_message(Some(ResultMessageData { message: view! { cx, { err.to_string() } - }.into_view(cx), + } + .into_view(cx), title: >::into(err).to_string(), colorway: Colorway::Bad, - })) + })), } }); }; @@ -146,4 +156,4 @@ fn App(cx: Scope) -> impl IntoView { pub fn main() { let root = document().query_selector("main").unwrap().unwrap(); mount_to(root.unchecked_into(), |cx| view! { cx, }); -} \ No newline at end of file +}