fix: apply clippy suggestions (#120)

* fix: apply clippy suggestions

* fmt

* clippy for linux targets
This commit is contained in:
Fabian-Lars
2023-02-01 11:27:33 +01:00
committed by GitHub
parent 2e515abba7
commit 4bb200aac5
8 changed files with 213 additions and 171 deletions
+3 -5
View File
@@ -154,7 +154,7 @@ pub fn sign(
let sig = encode_config(sign_data, URL_SAFE_NO_PAD);
println!("Sign result: {}", sig);
println!("Sign result: {sig}");
println!(
"Key handle used: {}",
encode_config(&handle_used, URL_SAFE_NO_PAD)
@@ -173,10 +173,8 @@ pub fn sign(
}
fn format_client_data(application: &str, challenge: &str) -> (Vec<u8>, Vec<u8>, String) {
let d = format!(
r#"{{"challenge": "{}", "version": "U2F_V2", "appId": "{}"}}"#,
challenge, application
);
let d =
format!(r#"{{"challenge": "{challenge}", "version": "U2F_V2", "appId": "{application}"}}"#);
let mut challenge = Sha256::new();
challenge.update(d.as_bytes());
let chall_bytes = challenge.finalize().to_vec();
+1 -1
View File
@@ -16,7 +16,7 @@ pub fn make_challenge(app_id: &str, challenge_bytes: Vec<u8>) -> Challenge {
let utc: DateTime<Utc> = Utc::now();
Challenge {
challenge: encode_config(challenge_bytes, URL_SAFE_NO_PAD),
timestamp: format!("{:?}", utc),
timestamp: format!("{utc:?}"),
app_id: app_id.to_string(),
}
}
+2 -2
View File
@@ -46,7 +46,7 @@ enum WatcherKind {
fn watch_raw<R: Runtime>(window: Window<R>, rx: Receiver<notify::Result<Event>>, id: Id) {
spawn(move || {
let event_name = format!("watcher://raw-event/{}", id);
let event_name = format!("watcher://raw-event/{id}");
while let Ok(event) = rx.recv() {
if let Ok(event) = event {
// TODO: Should errors be emitted too?
@@ -58,7 +58,7 @@ fn watch_raw<R: Runtime>(window: Window<R>, rx: Receiver<notify::Result<Event>>,
fn watch_debounced<R: Runtime>(window: Window<R>, rx: Receiver<DebounceEventResult>, id: Id) {
spawn(move || {
let event_name = format!("watcher://debounced-event/{}", id);
let event_name = format!("watcher://debounced-event/{id}");
while let Ok(event) = rx.recv() {
if let Ok(event) = event {
// TODO: Should errors be emitted too?
+2 -2
View File
@@ -62,8 +62,8 @@ impl Builder {
.setup(move |app| {
let asset_resolver = app.asset_resolver();
std::thread::spawn(move || {
let server = Server::http(&format!("localhost:{}", port))
.expect("Unable to spawn server");
let server =
Server::http(&format!("localhost:{port}")).expect("Unable to spawn server");
for req in server.incoming_requests() {
let path = req
.url()
+1 -1
View File
@@ -308,7 +308,7 @@ fn get_log_file_path(
rotation_strategy: &RotationStrategy,
max_file_size: u128,
) -> plugin::Result<PathBuf> {
let path = dir.as_ref().join(format!("{}.log", app_name));
let path = dir.as_ref().join(format!("{app_name}.log"));
if path.exists() {
let log_size = File::open(&path)?.metadata()?.len() as u128;
@@ -38,8 +38,8 @@ pub fn init<R: Runtime>(f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
callback: f,
app_handle: app.clone(),
};
let dbus_name = format!("org.{}.SingleInstance", id);
let dbus_path = format!("/org/{}/SingleInstance", id);
let dbus_name = format!("org.{id}.SingleInstance");
let dbus_path = format!("/org/{id}/SingleInstance");
match ConnectionBuilder::session()
.unwrap()
@@ -31,9 +31,9 @@ pub fn init<R: Runtime>(f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
.setup(|app| {
let id = &app.config().tauri.bundle.identifier;
let class_name = encode_wide(format!("{}-sic", id));
let window_name = encode_wide(format!("{}-siw", id));
let mutex_name = encode_wide(format!("{}-sim", id));
let class_name = encode_wide(format!("{id}-sic"));
let window_name = encode_wide(format!("{id}-siw"));
let mutex_name = encode_wide(format!("{id}-sim"));
let hmutex =
unsafe { CreateMutexW(std::ptr::null(), true.into(), mutex_name.as_ptr()) };