From 66a0c8f02a3bd5cffba98101aad9bedaf5ced44f Mon Sep 17 00:00:00 2001 From: victorrhgap Date: Mon, 30 Mar 2026 21:13:16 -0600 Subject: [PATCH] fix: update rand 0.8 API calls to rand 0.10 - thread_rng() -> rng() - RngCore/fill_bytes -> RngExt/fill - OsRng.fill_bytes -> rng().fill - gen_range -> random_range - Rng -> RngExt trait import cc --- src-tauri/src/artist_vectors/suggestions.rs | 2 +- src-tauri/src/config/remote_control_settings.rs | 4 ++-- src-tauri/src/credentials/mod.rs | 8 ++++---- src-tauri/src/queue/mod.rs | 4 ++-- src-tauri/src/reco_store/commands.rs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/artist_vectors/suggestions.rs b/src-tauri/src/artist_vectors/suggestions.rs index e403c409f..e402608a1 100644 --- a/src-tauri/src/artist_vectors/suggestions.rs +++ b/src-tauri/src/artist_vectors/suggestions.rs @@ -447,7 +447,7 @@ impl SuggestionsEngine { // 6. Shuffle tracks for variety (so same artist doesn't dominate) use rand::seq::SliceRandom; - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); all_tracks.shuffle(&mut rng); // 7. Limit pool size diff --git a/src-tauri/src/config/remote_control_settings.rs b/src-tauri/src/config/remote_control_settings.rs index 86a894d9e..e509814d8 100644 --- a/src-tauri/src/config/remote_control_settings.rs +++ b/src-tauri/src/config/remote_control_settings.rs @@ -6,7 +6,7 @@ //! - token: pairing token used by the remote control PWA use base64::Engine; -use rand::RngCore; +use rand::RngExt; use rusqlite::{params, Connection}; use serde::{Deserialize, Serialize}; use std::path::Path; @@ -248,7 +248,7 @@ impl RemoteControlSettingsState { fn generate_token() -> String { let mut bytes = [0u8; 32]; - rand::thread_rng().fill_bytes(&mut bytes); + rand::rng().fill(&mut bytes); base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(bytes) } diff --git a/src-tauri/src/credentials/mod.rs b/src-tauri/src/credentials/mod.rs index c0bed00ea..5ba072bb2 100644 --- a/src-tauri/src/credentials/mod.rs +++ b/src-tauri/src/credentials/mod.rs @@ -12,7 +12,7 @@ use aes_gcm::{ }; use base64::{engine::general_purpose::STANDARD as BASE64, Engine}; use keyring::Entry; -use rand::RngCore; +use rand::RngExt; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use std::fs; @@ -89,7 +89,7 @@ fn load_or_create_installation_salt() -> Result, String> { } let mut salt = [0u8; 32]; - rand::rngs::OsRng.fill_bytes(&mut salt); + rand::rng().fill(&mut salt); fs::write(&path, BASE64.encode(salt)) .map_err(|e| format!("Failed to write installation salt: {}", e))?; @@ -119,7 +119,7 @@ fn load_or_create_machine_id_fallback() -> Result, String> { } let mut machine_fallback = [0u8; 32]; - rand::rngs::OsRng.fill_bytes(&mut machine_fallback); + rand::rng().fill(&mut machine_fallback); fs::write(&path, BASE64.encode(machine_fallback)) .map_err(|e| format!("Failed to write machine fallback id: {}", e))?; @@ -178,7 +178,7 @@ fn encrypt_credentials(credentials: &QobuzCredentials) -> Result // Generate random nonce let mut nonce_raw = [0u8; 12]; - rand::rngs::OsRng.fill_bytes(&mut nonce_raw); + rand::rng().fill(&mut nonce_raw); let nonce_bytes: [u8; 12] = aes_gcm::aead::generic_array::GenericArray::from(nonce_raw).into(); let nonce = Nonce::from_slice(&nonce_bytes); diff --git a/src-tauri/src/queue/mod.rs b/src-tauri/src/queue/mod.rs index c1f7aabec..767d8c785 100644 --- a/src-tauri/src/queue/mod.rs +++ b/src-tauri/src/queue/mod.rs @@ -724,7 +724,7 @@ impl QueueManager { return; } - use rand::{Rng, SeedableRng}; + use rand::{RngExt, SeedableRng}; use std::time::{SystemTime, UNIX_EPOCH}; // Create seeded RNG from current timestamp @@ -736,7 +736,7 @@ impl QueueManager { // Proper Fisher-Yates shuffle - each iteration gets a NEW random number for i in (1..order.len()).rev() { - let j = rng.gen_range(0..=i); + let j = rng.random_range(0..=i); order.swap(i, j); } } diff --git a/src-tauri/src/reco_store/commands.rs b/src-tauri/src/reco_store/commands.rs index 2efbcc619..4f5b63945 100644 --- a/src-tauri/src/reco_store/commands.rs +++ b/src-tauri/src/reco_store/commands.rs @@ -901,7 +901,7 @@ pub async fn reco_get_home_resolved( // Shuffle artists so every favorite gets a fair chance let shuffled_artists = { let mut ids = favorite_artist_ids.clone(); - ids.shuffle(&mut rand::thread_rng()); + ids.shuffle(&mut rand::rng()); ids }; @@ -958,7 +958,7 @@ pub async fn reco_get_home_resolved( let mut seen = std::collections::HashSet::new(); all_albums.retain(|a| seen.insert(a.id.clone())); } - all_albums.shuffle(&mut rand::thread_rng()); + all_albums.shuffle(&mut rand::rng()); all_albums.truncate(limit_favorites as usize); all_albums };