diff --git a/.gitignore b/.gitignore index a1aaaf050..3c983c153 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ +# Rust target directories target +target-analyzer # Redis dump /dump.rdb diff --git a/.vscode/settings.json b/.vscode/settings.json index 37caee8fa..4c6d93bce 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,15 @@ { - "nixEnvSelector.nixFile": "${workspaceRoot}/flake.nix", - "rust-analyzer.cargo.buildScripts.enable": true, - "editor.formatOnSave": true, - "rust-analyzer.showUnlinkedFileNotification": false, - "rust-analyzer.cargo.features": ["oidc"] + "nixEnvSelector.nixFile": "${workspaceRoot}/flake.nix", + "rust-analyzer.cargo.buildScripts.enable": true, + "editor.formatOnSave": true, + "rust-analyzer.showUnlinkedFileNotification": false, + "rust-analyzer.cargo.features": [ + "oidc" + ], + "rust-analyzer.check.extraArgs": [ + "--target-dir=target-analyzer" + ], + "rust-analyzer.server.extraEnv": { + "CARGO_TARGET_DIR": "target-analyzer" + } } diff --git a/crates/kitsune-core/src/mapping/mastodon/sealed.rs b/crates/kitsune-core/src/mapping/mastodon/sealed.rs index e5c6a59ec..51d3cbaca 100644 --- a/crates/kitsune-core/src/mapping/mastodon/sealed.rs +++ b/crates/kitsune-core/src/mapping/mastodon/sealed.rs @@ -43,7 +43,7 @@ use scoped_futures::ScopedFutureExt; use serde::{de::DeserializeOwned, Serialize}; use smol_str::SmolStr; use speedy_uuid::Uuid; -use std::str::FromStr; +use std::{fmt::Write, str::FromStr}; #[derive(Clone, Copy)] pub struct MapperState<'a> { @@ -103,8 +103,7 @@ impl IntoMastodon for DbAccount { let mut acct = self.username.clone(); if !self.local { - acct.push('@'); - acct.push_str(&self.domain); + let _ = write!(acct, "@{}", self.domain); } let avatar = if let Some(avatar_id) = self.avatar_id { diff --git a/crates/kitsune-http-signatures/src/header.rs b/crates/kitsune-http-signatures/src/header.rs index cfcdfa489..2e7db914d 100644 --- a/crates/kitsune-http-signatures/src/header.rs +++ b/crates/kitsune-http-signatures/src/header.rs @@ -3,6 +3,7 @@ use derive_builder::Builder; use http::{header::DATE, request::Parts}; use std::{ cmp::min, + fmt::Write, time::{Duration, SystemTime, SystemTimeError}, }; use time::{format_description::well_known::Rfc2822, OffsetDateTime}; @@ -130,19 +131,23 @@ impl TryFrom> for String { ); if let Some(algorithm) = value.algorithm { - signature_header.push_str(",algorithm=\""); - signature_header.push_str(algorithm); - signature_header.push('"'); + let _ = write!(signature_header, ",algorithm=\"{algorithm}\""); } if let Some(created) = value.created { - signature_header.push_str(",created="); - signature_header.push_str(&created.to_unix_timestamp()?.to_string()); + let _ = write!( + signature_header, + ",created={}", + created.to_unix_timestamp()? + ); } if let Some(expires) = value.expires { - signature_header.push_str(",expires="); - signature_header.push_str(&expires.to_unix_timestamp()?.to_string()); + let _ = write!( + signature_header, + ",expires={}", + expires.to_unix_timestamp()? + ); } Ok(signature_header)