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
This commit is contained in:
victorrhgap committed 2026-03-30 21:13:16 -06:00
1 parent f9c32a25a9
commit 66a0c8f02a
5 files changed
+11 -11

No files matched your search

+1 -1
View File
@@ -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
@@ -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)
}
+4 -4
View File
@@ -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<Vec<u8>, 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<Vec<u8>, 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<String, String>
// 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);
+2 -2
View File
@@ -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);
}
}
+2 -2
View File
@@ -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
};