Skip to content

Commit e4127a1

Browse files
dependabot[bot]crepererum
authored andcommitted
chore(deps): update rand requirement from 0.9 to 0.10
Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](rust-random/rand@rand_core-0.9.1...0.10.0) --- updated-dependencies: - dependency-name: rand dependency-version: 0.10.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
1 parent 049970a commit e4127a1

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ futures = "0.3"
2828
integer-encoding = "4"
2929
lz4 = { version = "1.23", optional = true }
3030
parking_lot = "0.12"
31-
rand = { version = "0.9", default-features = false, features = ["thread_rng"] }
31+
rand = { version = "0.10", default-features = false, features = ["thread_rng"] }
3232
rustls = { version = "0.23", optional = true, default-features = false, features = ["logging", "ring", "std", "tls12"] }
3333
snap = { version = "1", optional = true }
3434
thiserror = "2.0"

src/backoff.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rand::prelude::*;
1+
use rand::{Rng, RngExt};
22
use std::ops::ControlFlow;
33
use std::time::Duration;
44
use tracing::info;
@@ -60,7 +60,7 @@ pub struct Backoff {
6060
base: f64,
6161
total: f64,
6262
deadline: Option<f64>,
63-
rng: Option<Box<dyn RngCore + Sync + Send>>,
63+
rng: Option<Box<dyn Rng + Sync + Send>>,
6464
}
6565

6666
impl std::fmt::Debug for Backoff {
@@ -83,10 +83,7 @@ impl Backoff {
8383
/// Creates a new `Backoff` with the optional `rng`
8484
///
8585
/// Used [`rand::rng()`] if no rng provided
86-
pub fn new_with_rng(
87-
config: &BackoffConfig,
88-
rng: Option<Box<dyn RngCore + Sync + Send>>,
89-
) -> Self {
86+
pub fn new_with_rng(config: &BackoffConfig, rng: Option<Box<dyn Rng + Sync + Send>>) -> Self {
9087
let init_backoff = config.init_backoff.as_secs_f64();
9188
Self {
9289
init_backoff,
@@ -175,6 +172,8 @@ impl Iterator for Backoff {
175172
#[cfg(test)]
176173
mod tests {
177174
use super::*;
175+
use rand::{TryRng, rand_core::utils::fill_bytes_via_next_word};
176+
use std::convert::Infallible;
178177

179178
#[test]
180179
fn test_backoff() {
@@ -243,17 +242,19 @@ mod tests {
243242
}
244243
}
245244

246-
impl RngCore for ConstantRng {
247-
fn next_u32(&mut self) -> u32 {
248-
(self.value >> 32) as u32
245+
impl TryRng for ConstantRng {
246+
type Error = Infallible;
247+
248+
fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
249+
Ok((self.value >> 32) as u32)
249250
}
250251

251-
fn next_u64(&mut self) -> u64 {
252-
self.value
252+
fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
253+
Ok(self.value)
253254
}
254255

255-
fn fill_bytes(&mut self, _dest: &mut [u8]) {
256-
unimplemented!()
256+
fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), Self::Error> {
257+
fill_bytes_via_next_word(dst, || self.try_next_u64())
257258
}
258259
}
259260
}

src/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rand::prelude::*;
1+
use rand::seq::SliceRandom;
22
use std::fmt::Display;
33
use std::future::Future;
44
use std::ops::ControlFlow;

0 commit comments

Comments
 (0)