From af6ae703cfbecbf6f49ff593a949429b9a558e17 Mon Sep 17 00:00:00 2001 From: James Brown Date: Mon, 20 Apr 2026 12:22:15 -0700 Subject: [PATCH] cli: bump rand to 0.9 --- svix-cli/Cargo.lock | 63 ++++++++----------------------------- svix-cli/Cargo.toml | 2 +- svix-cli/src/cmds/seed.rs | 6 ++-- svix-cli/src/relay/token.rs | 16 +++++----- 4 files changed, 24 insertions(+), 63 deletions(-) diff --git a/svix-cli/Cargo.lock b/svix-cli/Cargo.lock index e4d3a6c725..20d8c9edf0 100644 --- a/svix-cli/Cargo.lock +++ b/svix-cli/Cargo.lock @@ -736,9 +736,9 @@ checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "hyper" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" dependencies = [ "atomic-waker", "bytes", @@ -750,7 +750,6 @@ dependencies = [ "httparse", "itoa", "pin-project-lite", - "pin-utils", "smallvec", "tokio", "want", @@ -1180,12 +1179,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - [[package]] name = "powerfmt" version = "0.2.0" @@ -1263,7 +1256,7 @@ dependencies = [ "bytes", "getrandom 0.3.4", "lru-slab", - "rand 0.9.2", + "rand", "ring", "rustc-hash", "rustls", @@ -1312,33 +1305,12 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" -dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.5", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", + "rand_chacha", + "rand_core", ] [[package]] @@ -1348,16 +1320,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.5", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.17", + "rand_core", ] [[package]] @@ -1455,9 +1418,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.37" +version = "0.23.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" +checksum = "69f9466fb2c14ea04357e91413efb882e2a6d4a406e625449bc0a5d360d53a21" dependencies = [ "aws-lc-rs", "log", @@ -1726,7 +1689,7 @@ dependencies = [ "itertools", "js_option", "percent-encoding", - "rand 0.9.2", + "rand", "rustls", "serde", "serde_json", @@ -1760,7 +1723,7 @@ dependencies = [ "idna_adapter", "indoc", "open", - "rand 0.8.5", + "rand", "reqwest", "rustls", "serde", @@ -2116,7 +2079,7 @@ dependencies = [ "http 1.4.0", "httparse", "log", - "rand 0.9.2", + "rand", "rustls", "rustls-pki-types", "sha1", diff --git a/svix-cli/Cargo.toml b/svix-cli/Cargo.toml index 6c01dfd312..461adb8e4d 100644 --- a/svix-cli/Cargo.toml +++ b/svix-cli/Cargo.toml @@ -45,7 +45,7 @@ http = "1.2.0" idna_adapter = "=1.1.0" indoc = "2.0.5" open = "5.3.1" -rand = "0.8.5" +rand = "0.9" reqwest = { version = "0.13.2", features = ["rustls", "json", "charset", "http2"], default-features = false } rustls = "0.23.34" serde = { version = "1.0.215", features = ["derive"] } diff --git a/svix-cli/src/cmds/seed.rs b/svix-cli/src/cmds/seed.rs index 2673f77a7a..b09e50961e 100644 --- a/svix-cli/src/cmds/seed.rs +++ b/svix-cli/src/cmds/seed.rs @@ -1,6 +1,6 @@ use anyhow::Context; use clap::Args; -use rand::{rngs::StdRng, seq::SliceRandom, SeedableRng}; +use rand::prelude::*; use serde::{Deserialize, Serialize}; use serde_json::json; use svix::api::*; @@ -162,10 +162,8 @@ async fn create_endpoint(client: Svix, app_id: String) -> anyhow::Result anyhow::Result { - let mut rng = StdRng::from_entropy(); - let event_type = USER_EVENT_TYPES - .choose(&mut rng) + .choose(&mut rand::rng()) .context("Couldn't pick a random event type while creating a message")?; let message_in = MessageIn { diff --git a/svix-cli/src/relay/token.rs b/svix-cli/src/relay/token.rs index 0cc1367975..8fd21da942 100644 --- a/svix-cli/src/relay/token.rs +++ b/svix-cli/src/relay/token.rs @@ -1,16 +1,16 @@ use anyhow::Result; -use rand::distributions::{Distribution, Uniform}; +use rand::distr::Distribution; const BASE62: &[u8; 62] = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; pub fn generate_token() -> Result { - let between = Uniform::from(0..BASE62.len()); - let mut rng = rand::thread_rng(); - let mut bytes = [0_u8; 27]; - for b in &mut bytes { - *b = BASE62[between.sample(&mut rng)]; - } - Ok(String::from_utf8(bytes.to_vec())?) + let distribution = rand::distr::slice::Choose::new(BASE62)?; + let mut rng = rand::rng(); + Ok(distribution + .sample_iter(&mut rng) + .take(10) + .map(|c| *c as char) + .collect::()) } #[cfg(test)]