From 33447c13d01993543d135c692aad0ac28f8bbd84 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Mon, 21 Aug 2023 21:59:27 -0700 Subject: [PATCH] cargo fmt --- .../src/components/keyboardfromfile.rs | 8 +++--- dyesub-tool/src/components/keyboardfromweb.rs | 8 +++--- dyesub-tool/src/components/mod.rs | 2 +- dyesub-tool/src/components/resultmessage.rs | 26 ++++++++++--------- dyesub-tool/src/error/fetchfile.rs | 5 ++-- dyesub-tool/src/error/fetchkle.rs | 11 +++++--- dyesub-tool/src/error/mod.rs | 2 +- dyesub-tool/src/error/readfile.rs | 7 ++--- dyesub-tool/src/error/readkle.rs | 2 +- dyesub-tool/src/main.rs | 8 +++--- dyesub-tool/src/models/colorway.rs | 2 +- dyesub-tool/src/models/mod.rs | 2 +- dyesub-tool/src/utils.rs | 15 ++++------- 13 files changed, 51 insertions(+), 47 deletions(-) diff --git a/dyesub-tool/src/components/keyboardfromfile.rs b/dyesub-tool/src/components/keyboardfromfile.rs index 8b82839..9a5ff38 100644 --- a/dyesub-tool/src/components/keyboardfromfile.rs +++ b/dyesub-tool/src/components/keyboardfromfile.rs @@ -1,8 +1,10 @@ -use leptos::{*, html::Input}; +use leptos::{html::Input, *}; use web_sys::File; -use crate::{components::ResultMessageData, utils::read_file, error::ReadKleError, models::Colorway}; use super::ResultMessage; +use crate::{ + components::ResultMessageData, error::ReadKleError, models::Colorway, utils::read_file, +}; #[component] pub fn KeyboardFromFile( @@ -61,4 +63,4 @@ async fn read_kle_from_file( file: ReadSignal>, ) -> Result { Ok(serde_json::from_str(&read_file(file).await?)?) -} \ No newline at end of file +} diff --git a/dyesub-tool/src/components/keyboardfromweb.rs b/dyesub-tool/src/components/keyboardfromweb.rs index c08e885..0be3101 100644 --- a/dyesub-tool/src/components/keyboardfromweb.rs +++ b/dyesub-tool/src/components/keyboardfromweb.rs @@ -1,8 +1,8 @@ -use leptos::{*, html::Input}; +use leptos::{html::Input, *}; use web_sys::SubmitEvent; -use crate::{error::FetchKleError, utils::fetch_file, models::Colorway}; use super::{ResultMessage, ResultMessageData}; +use crate::{error::FetchKleError, models::Colorway, utils::fetch_file}; async fn fetch_layout(url: &str) -> Result { let layout_string = fetch_file(url).await?; @@ -31,7 +31,7 @@ pub fn KeyboardFromWeb( colorway: Colorway::Ok, })); set_keyboard(Some(keyboard)); - }, + } Err(err) => { set_result_message(Some(ResultMessageData { message: view! { cx, @@ -56,4 +56,4 @@ pub fn KeyboardFromWeb( } -} \ No newline at end of file +} diff --git a/dyesub-tool/src/components/mod.rs b/dyesub-tool/src/components/mod.rs index 07277d9..d9229fc 100644 --- a/dyesub-tool/src/components/mod.rs +++ b/dyesub-tool/src/components/mod.rs @@ -5,4 +5,4 @@ mod keyboardfromfile; pub use keyboardfromfile::KeyboardFromFile; mod keyboardfromweb; -pub use keyboardfromweb::KeyboardFromWeb; \ No newline at end of file +pub use keyboardfromweb::KeyboardFromWeb; diff --git a/dyesub-tool/src/components/resultmessage.rs b/dyesub-tool/src/components/resultmessage.rs index 5ce29b3..6e13e02 100644 --- a/dyesub-tool/src/components/resultmessage.rs +++ b/dyesub-tool/src/components/resultmessage.rs @@ -1,5 +1,5 @@ -use leptos::*; use class_list::class_list; +use leptos::*; use crate::models::Colorway; @@ -17,15 +17,17 @@ pub fn ResultMessage(cx: Scope, message: ReadSignal>) message.track(); set_open(true); }); - move || view! { cx, - - {move || message().map(|ResultMessageData { title, message, colorway }| view! { cx, -
- {title} - -

{message}

-
- })} -
+ move || { + view! { cx, + + {move || message().map(|ResultMessageData { title, message, colorway }| view! { cx, +
+ {title} + +

{message}

+
+ })} +
+ } } -} \ No newline at end of file +} diff --git a/dyesub-tool/src/error/fetchfile.rs b/dyesub-tool/src/error/fetchfile.rs index 5538855..ed7bfc7 100644 --- a/dyesub-tool/src/error/fetchfile.rs +++ b/dyesub-tool/src/error/fetchfile.rs @@ -16,6 +16,7 @@ impl ToString for FetchFileError { match self { Request(error) => error.as_string(), _ => None, - }.unwrap_or_else(|| "".to_string()) + } + .unwrap_or_else(|| "".to_string()) } -} \ No newline at end of file +} diff --git a/dyesub-tool/src/error/fetchkle.rs b/dyesub-tool/src/error/fetchkle.rs index a711c13..2844f22 100644 --- a/dyesub-tool/src/error/fetchkle.rs +++ b/dyesub-tool/src/error/fetchkle.rs @@ -5,7 +5,9 @@ use super::FetchFileError; #[derive(From, IntoStaticStr)] pub enum FetchKleError { - #[strum(serialize = "Invalid source. Must be KLE layout, gist URL, gist ID, or direct URL to JSON file")] + #[strum( + serialize = "Invalid source. Must be KLE layout, gist URL, gist ID, or direct URL to JSON file" + )] InvalidSource, #[strum(serialize = "Failed to fetch file")] FetchFile(FetchFileError), @@ -25,11 +27,12 @@ impl ToString for FetchKleError { full_error.push_str(&error_info); } full_error - }, + } FetchFileError::ReadToString => error.to_string(), }), Serde(error) => Some(error.to_string()), _ => None, - }.unwrap_or_else(|| "".to_string()) + } + .unwrap_or_else(|| "".to_string()) } -} \ No newline at end of file +} diff --git a/dyesub-tool/src/error/mod.rs b/dyesub-tool/src/error/mod.rs index 1f2303b..7e1ac15 100644 --- a/dyesub-tool/src/error/mod.rs +++ b/dyesub-tool/src/error/mod.rs @@ -8,4 +8,4 @@ mod fetchkle; pub use fetchkle::FetchKleError; mod readkle; -pub use readkle::ReadKleError; \ No newline at end of file +pub use readkle::ReadKleError; diff --git a/dyesub-tool/src/error/readfile.rs b/dyesub-tool/src/error/readfile.rs index 10ac191..50a5955 100644 --- a/dyesub-tool/src/error/readfile.rs +++ b/dyesub-tool/src/error/readfile.rs @@ -17,7 +17,8 @@ impl ToString for ReadFileError { use ReadFileError::*; match self { TextAwait(error) => error.as_string(), - _ => None - }.unwrap_or_else(|| "".to_string()) + _ => None, + } + .unwrap_or_else(|| "".to_string()) } -} \ No newline at end of file +} diff --git a/dyesub-tool/src/error/readkle.rs b/dyesub-tool/src/error/readkle.rs index dc8aa5f..dc3f5f1 100644 --- a/dyesub-tool/src/error/readkle.rs +++ b/dyesub-tool/src/error/readkle.rs @@ -18,4 +18,4 @@ impl ToString for ReadKleError { Serde(error) => error.to_string(), } } -} \ No newline at end of file +} diff --git a/dyesub-tool/src/main.rs b/dyesub-tool/src/main.rs index 3e48724..4f7358a 100644 --- a/dyesub-tool/src/main.rs +++ b/dyesub-tool/src/main.rs @@ -1,13 +1,13 @@ #![feature(async_closure)] -#[allow(dead_code)] -mod render; -mod error; mod components; -mod utils; +mod error; mod models; #[allow(dead_code)] +mod render; +#[allow(dead_code)] pub mod svg; +mod utils; use leptos::*; use wasm_bindgen::JsCast; diff --git a/dyesub-tool/src/models/colorway.rs b/dyesub-tool/src/models/colorway.rs index cf32ae7..c2128ee 100644 --- a/dyesub-tool/src/models/colorway.rs +++ b/dyesub-tool/src/models/colorway.rs @@ -22,4 +22,4 @@ impl ClassList for Colorway { let class: &str = self.into(); class.to_string() } -} \ No newline at end of file +} diff --git a/dyesub-tool/src/models/mod.rs b/dyesub-tool/src/models/mod.rs index 5aad77f..e260b2a 100644 --- a/dyesub-tool/src/models/mod.rs +++ b/dyesub-tool/src/models/mod.rs @@ -1,2 +1,2 @@ mod colorway; -pub use colorway::Colorway; \ No newline at end of file +pub use colorway::Colorway; diff --git a/dyesub-tool/src/utils.rs b/dyesub-tool/src/utils.rs index c920213..012b92f 100644 --- a/dyesub-tool/src/utils.rs +++ b/dyesub-tool/src/utils.rs @@ -1,24 +1,19 @@ use leptos::*; use wasm_bindgen_futures::JsFuture; -use web_sys::{File, Window, Request}; +use web_sys::{File, Request, Window}; -use crate::error::{ReadFileError, FetchFileError}; +use crate::error::{FetchFileError, ReadFileError}; pub fn window() -> Window { web_sys::window().unwrap() } -pub async fn read_file( - file: ReadSignal>, -) -> Result { +pub async fn read_file(file: ReadSignal>) -> Result { let file = match file() { Some(file) => file, None => return Err(ReadFileError::NoFile), }; - match JsFuture::from(file.text()) - .await? - .as_string() - { + match JsFuture::from(file.text()).await?.as_string() { Some(contents) => Ok(contents), None => Err(ReadFileError::ParseToString), } @@ -31,4 +26,4 @@ pub async fn fetch_file(url: &str) -> Result { Some(string) => Ok(string), None => Err(FetchFileError::ReadToString), } -} \ No newline at end of file +}