This is an automated email from the ASF dual-hosted git repository.
mneumann pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs-object-store.git
The following commit(s) were added to refs/heads/main by this push:
new 030f29d chore: upgrade to `rand` 0.10 (#637)
030f29d is described below
commit 030f29d59ec055741e5f4de55e8a004d8fa44d5b
Author: Marco Neumann <[email protected]>
AuthorDate: Thu Feb 12 17:59:12 2026 +0100
chore: upgrade to `rand` 0.10 (#637)
---
Cargo.toml | 11 ++++++++---
src/azure/client.rs | 2 +-
src/client/backoff.rs | 27 ++++++++++++++++-----------
src/integration.rs | 2 +-
src/upload.rs | 2 +-
src/util.rs | 2 +-
6 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 7e036e3..061bf5a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -53,7 +53,7 @@ httparse = { version = "1.8.0", default-features = false,
features = ["std"], op
hyper = { version = "1.2", default-features = false, optional = true }
md-5 = { version = "0.10.6", default-features = false, optional = true }
quick-xml = { version = "0.39.0", features = ["serialize",
"overlapped-lists"], optional = true }
-rand = { version = "0.9", default-features = false, features = ["std",
"std_rng", "thread_rng"], optional = true }
+rand = { version = "0.10", default-features = false, features = ["std",
"std_rng", "thread_rng"], optional = true }
reqwest = { version = "0.12", default-features = false, features =
["rustls-tls-native-roots", "http2"], optional = true }
ring = { version = "0.17", default-features = false, features = ["std"],
optional = true }
rustls-pki-types = { version = "1.9", default-features = false, features =
["std"], optional = true }
@@ -83,7 +83,7 @@ integration = ["rand"]
[dev-dependencies] # In alphabetical order
hyper = { version = "1.2", features = ["server"] }
hyper-util = "0.1"
-rand = "0.9"
+rand = "0.10"
tempfile = "3.1.0"
regex = "1.11.1"
# The "gzip" feature for reqwest is enabled for an integration test.
@@ -92,6 +92,11 @@ reqwest = { version = "0.12", default-features = false,
features = ["gzip"] }
[target.'cfg(all(target_arch = "wasm32", target_os =
"unknown"))'.dev-dependencies]
wasm-bindgen-test = "0.3.50"
+[dev-dependencies.getrandom_v04]
+package = "getrandom"
+version = "0.4"
+features = ["wasm_js"]
+
[dev-dependencies.getrandom_v03]
package = "getrandom"
version = "0.3"
@@ -105,4 +110,4 @@ features = ["js"]
[[test]]
name = "get_range_file"
path = "tests/get_range_file.rs"
-required-features = ["fs"]
\ No newline at end of file
+required-features = ["fs"]
diff --git a/src/azure/client.rs b/src/azure/client.rs
index e068c4b..6f1ad23 100644
--- a/src/azure/client.rs
+++ b/src/azure/client.rs
@@ -40,7 +40,7 @@ use http::{
HeaderName, Method,
header::{CONTENT_LENGTH, CONTENT_TYPE, HeaderMap, HeaderValue, IF_MATCH,
IF_NONE_MATCH},
};
-use rand::Rng as _;
+use rand::RngExt;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::Arc;
diff --git a/src/client/backoff.rs b/src/client/backoff.rs
index e1160d6..f3f18da 100644
--- a/src/client/backoff.rs
+++ b/src/client/backoff.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-use rand::{prelude::*, rng};
+use rand::{Rng, RngExt, rng};
use std::time::Duration;
/// Exponential backoff with decorrelated jitter algorithm
@@ -56,7 +56,7 @@ pub(crate) struct Backoff {
next_backoff_secs: f64,
max_backoff_secs: f64,
base: f64,
- rng: Option<Box<dyn RngCore + Sync + Send>>,
+ rng: Option<Box<dyn Rng + Sync + Send>>,
}
impl std::fmt::Debug for Backoff {
@@ -81,7 +81,7 @@ impl Backoff {
/// Used [`rand::rng()`] if no rng provided
pub(crate) fn new_with_rng(
config: &BackoffConfig,
- rng: Option<Box<dyn RngCore + Sync + Send>>,
+ rng: Option<Box<dyn Rng + Sync + Send>>,
) -> Self {
let init_backoff = config.init_backoff.as_secs_f64();
Self {
@@ -109,22 +109,27 @@ impl Backoff {
#[cfg(test)]
mod tests {
+ use std::convert::Infallible;
+
+ use rand::{TryRng, rand_core::utils::fill_bytes_via_next_word};
+
use super::*;
- use rand::rand_core::impls::fill_bytes_via_next;
struct FixedRng(u64);
- impl RngCore for FixedRng {
- fn next_u32(&mut self) -> u32 {
- self.0 as _
+ impl TryRng for FixedRng {
+ type Error = Infallible;
+
+ fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
+ Ok(self.0 as _)
}
- fn next_u64(&mut self) -> u64 {
- self.0
+ fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
+ Ok(self.0)
}
- fn fill_bytes(&mut self, dst: &mut [u8]) {
- fill_bytes_via_next(self, dst)
+ fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(),
Self::Error> {
+ fill_bytes_via_next_word(dst, || self.try_next_u64())
}
}
diff --git a/src/integration.rs b/src/integration.rs
index b0672db..731f7d2 100644
--- a/src/integration.rs
+++ b/src/integration.rs
@@ -34,7 +34,7 @@ use crate::{
use bytes::Bytes;
use futures::stream::FuturesUnordered;
use futures::{StreamExt, TryStreamExt};
-use rand::{Rng, rng};
+use rand::{RngExt, rng};
use std::collections::HashSet;
use std::slice;
diff --git a/src/upload.rs b/src/upload.rs
index 33698a4..9f6b9ee 100644
--- a/src/upload.rs
+++ b/src/upload.rs
@@ -246,7 +246,7 @@ mod tests {
use futures::FutureExt;
use parking_lot::Mutex;
use rand::prelude::StdRng;
- use rand::{Rng, SeedableRng};
+ use rand::{RngExt, SeedableRng};
use crate::ObjectStoreExt;
use crate::memory::InMemory;
diff --git a/src/util.rs b/src/util.rs
index b7f9182..565c1ce 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -331,7 +331,7 @@ mod tests {
use crate::Error;
use super::*;
- use rand::{Rng, rng};
+ use rand::{RngExt, rng};
use std::ops::Range;
/// Calls coalesce_ranges and validates the returned data is correct