Skip to content

Commit

Permalink
rand_core: 0.6 -> 0.9
Browse files Browse the repository at this point in the history
The mqtt and tls crates have not been updated yet due to the p256 crate
depending on an older version of rand_core.
  • Loading branch information
newAM committed Jan 29, 2025
1 parent 1da9aec commit 8de8d35
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dhcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ log = { version = "0.4", optional = true }

[dev-dependencies]
dhcproto = "0.12"
rand_core = { version = "0.6", features = ["getrandom"] }
rand_core = { version = "0.9", features = ["os_rng"] }
stderrlog = "0.6"
w5500-hl.path = "../hl"
w5500-regsim.path = "../regsim"
Expand Down
16 changes: 8 additions & 8 deletions dhcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub enum State {
/// # Example
///
/// ```no_run
/// use rand_core::RngCore;
/// use rand_core::TryRngCore;
/// use w5500_dhcp::{
/// ll::{net::Eui48Addr, Sn},
/// Client, Hostname,
Expand All @@ -97,7 +97,7 @@ pub enum State {
///
/// this_is_where_you_setup_the_w5500_int_pin_for_a_falling_edge_trigger();
///
/// let seed: u64 = rng.next_u64();
/// let seed: u64 = rng.try_next_u64().unwrap();
///
/// let mut dhcp: Client = Client::new(DHCP_SN, seed, MAC_ADDRESS, HOSTNAME);
///
Expand Down Expand Up @@ -156,7 +156,7 @@ impl<'a> Client<'a> {
/// # Example
///
/// ```
/// use rand_core::RngCore;
/// use rand_core::TryRngCore;
/// use w5500_dhcp::{
/// ll::{net::Eui48Addr, Sn},
/// Client, Hostname,
Expand All @@ -167,7 +167,7 @@ impl<'a> Client<'a> {
/// // locally administered MAC address
/// const MAC_ADDRESS: Eui48Addr = Eui48Addr::new(0x02, 0x00, 0x11, 0x22, 0x33, 0x44);
/// const HOSTNAME: Hostname = Hostname::new_unwrapped("example");
/// let seed: u64 = rng.next_u64();
/// let seed: u64 = rng.try_next_u64().unwrap();
///
/// let dhcp: Client = Client::new(DHCP_SN, seed, MAC_ADDRESS, HOSTNAME);
/// ```
Expand Down Expand Up @@ -206,7 +206,7 @@ impl<'a> Client<'a> {
/// Set a 10 second timeout.
///
/// ```
/// use rand_core::RngCore;
/// use rand_core::TryRngCore;
/// use w5500_dhcp::{
/// ll::{net::Eui48Addr, Sn},
/// Client, Hostname,
Expand All @@ -216,7 +216,7 @@ impl<'a> Client<'a> {
/// const HOSTNAME: Hostname = Hostname::new_unwrapped("example");
/// let mut dhcp: Client = Client::new(
/// Sn::Sn0,
/// rng.next_u64(),
/// rng.try_next_u64().unwrap(),
/// Eui48Addr::new(0x02, 0x00, 0x11, 0x22, 0x33, 0x44),
/// HOSTNAME,
/// );
Expand All @@ -231,7 +231,7 @@ impl<'a> Client<'a> {
/// # Example
///
/// ```
/// use rand_core::RngCore;
/// use rand_core::TryRngCore;
/// use w5500_dhcp::{
/// ll::{net::Eui48Addr, Sn},
/// Client, Hostname,
Expand All @@ -241,7 +241,7 @@ impl<'a> Client<'a> {
/// const HOSTNAME: Hostname = Hostname::new_unwrapped("example");
/// let dhcp: Client = Client::new(
/// Sn::Sn0,
/// rng.next_u64(),
/// rng.try_next_u64().unwrap(),
/// Eui48Addr::new(0x02, 0x00, 0x11, 0x22, 0x33, 0x44),
/// HOSTNAME,
/// );
Expand Down
2 changes: 1 addition & 1 deletion dns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ log = { version = "0.4", optional = true }

[dev-dependencies]
log = "0.4"
rand_core = { version = "0.6", features = ["getrandom"] }
rand_core = { version = "0.9", features = ["os_rng"] }
stderrlog = "0.6"
w5500-regsim.path = "../regsim"

Expand Down
6 changes: 4 additions & 2 deletions dns/examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! **Note:** This will communicate with external network services.
use rand_core::{OsRng, RngCore};
use rand_core::{OsRng, TryRngCore};
use std::time::{Duration, Instant};
use w5500_dns::{
hl::{Error, Udp},
Expand Down Expand Up @@ -34,7 +34,9 @@ fn main() {
.udp_bind(DNS_SOCKET, DNS_SOURCE_PORT)
.expect("failed to bind");

let random_number: u64 = OsRng.next_u64();
let random_number: u64 = OsRng
.try_next_u64()
.expect("Failed to generate random number");

let mut dns_client: Client = Client::new(
Sn::Sn3,
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ publish = false
edition = "2021"

[dependencies]
rand_core = "0.6"
rand_core = { version = "0.9", features = ["os_rng"] }
w5500-ll.path = "../ll"
6 changes: 0 additions & 6 deletions fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ impl rand_core::RngCore for NotRng {
fn fill_bytes(&mut self, dest: &mut [u8]) {
dest.iter_mut().for_each(|b| *b = self.next_byte());
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
dest.iter_mut().for_each(|b| *b = self.next_byte());
Ok(())
}
}

impl rand_core::CryptoRng for NotRng {}
2 changes: 1 addition & 1 deletion testsuite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
ftdi-embedded-hal = { version = "0.22.0", features = ["libftd2xx", "libftd2xx-static"] }
log = "0.4"
rand_core = { version = "0.6.3", features = ["getrandom"] }
rand_core = { version = "0.6", features = ["getrandom"] }
stderrlog = "0.6"

w5500-dhcp = { path = "../dhcp", features = ["eh1", "log"] }
Expand Down
2 changes: 1 addition & 1 deletion tls/afl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
afl = "0.15"
rand_core = "0.6"
rand_core = "0.9"
stderrlog = "0.6"
w5500-fuzz.path = "../../fuzz"
w5500-regsim.path = "../../regsim"
Expand Down

0 comments on commit 8de8d35

Please sign in to comment.