From 9271bce02a991fafe6c61e376b39601dcb23c22c Mon Sep 17 00:00:00 2001 From: IndyV <28678264+IndyV@users.noreply.github.com> Date: Wed, 15 Feb 2023 21:29:25 +0100 Subject: [PATCH] Small cleanup --- README.md | 14 +++++++++++--- src/purge_online.rs | 11 ++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 980de22..26e2872 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ -# ShareXtended +

ShareXtended

+ +

+ + Build status + +

A Rusty program that provides ShareX utility commands. @@ -15,8 +21,8 @@ Options: -h, --help Print help information -V, --version Print version information ``` -> If `[COMMAND]` is not specified the program will run in interactive mode. +> If `[COMMAND]` is not specified the program will run in interactive mode. ## Motivation @@ -28,6 +34,7 @@ Recently I just wanted to try out [the most loved language](https://survey.stack So I decided to try Rust, and it worked like a charm. Yes, I know this project could have also been done in many other (easier) ways, like: + - C#, powerful and also matching the language of the ShareX project. - Or even simpler as a Powershell or Python script probably @@ -36,8 +43,8 @@ But this project wasn't for any business related task and I wanted to try out Ru It's a bit hard to get started with due to these new concepts, like ownership, borrowing, and lifetimes, but I really like it. It's a very powerful language with great error messages and many useful crates. I'm looking forward to learn more about it. - ### Code + Watching video's from [No Boilerplate](https://www.youtube.com/c/NoBoilerplate) motivated me to try out Rust. On advise about your Rust toolkit, he suggested the following Clippy lints: ```ps1 @@ -51,6 +58,7 @@ I tried to store the static strings in the `Cargo.toml`, but I figured it's not I used https://transform.tools/json-to-rust-serde as a reference for the JSON structure. #### Crates used + - `eyre`: For simple error reporting - `tokyo` & `futures`: For writing async Rust - `serde` & `serde_json`: For (JSON) Serialization/Deserialization diff --git a/src/purge_online.rs b/src/purge_online.rs index 022be1e..100a8a9 100644 --- a/src/purge_online.rs +++ b/src/purge_online.rs @@ -10,19 +10,14 @@ use serde::{Deserialize, Serialize}; use std::{io::Read, path::PathBuf}; #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] +#[serde(rename_all = "PascalCase")] struct HistoryItem { - #[serde(rename = "FileName")] pub file_name: String, - #[serde(rename = "FilePath")] pub file_path: Option, - #[serde(rename = "DateTime")] pub date_time: DateTime, #[serde(rename = "Type")] pub type_field: String, - #[serde(rename = "Host")] pub host: String, - #[serde(rename = "Tags")] pub tags: Option, #[serde(rename = "URL")] pub url: Option, @@ -33,11 +28,9 @@ struct HistoryItem { } #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] +#[serde(rename_all = "PascalCase")] struct Tags { - #[serde(rename = "WindowTitle")] pub window_title: Option, - #[serde(rename = "ProcessName")] pub process_name: String, }