From 60f81f6d4e7a8b576099406d917cffcda014c6be Mon Sep 17 00:00:00 2001 From: javalsai Date: Tue, 24 Mar 2026 23:48:33 +0100 Subject: [PATCH] dev: reduce build sizes (especially debug) --- Cargo.toml | 11 +++++++++++ src/utils.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 87c4cf7..cbd3ce0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,19 @@ keywords = ["oauth", "oauth2", "oidc", "OpenID"] categories = ["web-programming::http-server", "authentication"] [profile.release] +lto = true strip = "symbols" # almost half of binary size smh +# so I don't need "full" just yet and the debug builds are HUGE +[profile.dev] +debug = 1 +[profile.dev.package.actix-web] +opt-level = 3 +debug = false +[profile.dev.package.tokio] +opt-level = 3 +debug = false + [features] default = ["pamsock"] pamsock = ["dep:pamsock"] diff --git a/src/utils.rs b/src/utils.rs index 3afc129..a619b5e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -37,3 +37,29 @@ pub mod web { } } } + +pub mod shasum { + #[must_use] + pub fn sha256sum_to_hex_string(sha256sum: &[u8]) -> String { + let mut out = String::with_capacity(sha256sum.len() * 2); + + for &b in sha256sum { + /// Only correct as long as `n` is ranged within a nibble + #[inline] + const fn nibble_to_hex(n: u8) -> char { + (match n { + 0..=9 => b'0' + n, + _ => b'a' + (n - 10), + }) as char + } + + let hi = (b >> 4) & 0x0f; + let lo = b & 0x0f; + + out.push(nibble_to_hex(hi)); + out.push(nibble_to_hex(lo)); + } + + out + } +}