From b8542e08197c8115981b17abca833a8a20dfde89 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Wed, 5 Feb 2025 14:00:00 -0500 Subject: [PATCH 1/2] Update getrandom to v0.3 in examples. Signed-off-by: Piotr Sikora --- examples/hello_world/Cargo.toml | 2 +- examples/hello_world/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index 42ebd269..4dbc3d4e 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -17,7 +17,7 @@ log = "0.4" proxy-wasm = { path = "../../" } [target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies] -getrandom = "0.2" +getrandom = "0.3" [profile.release] lto = true diff --git a/examples/hello_world/src/lib.rs b/examples/hello_world/src/lib.rs index 7eb1cc64..7b7cbee6 100644 --- a/examples/hello_world/src/lib.rs +++ b/examples/hello_world/src/lib.rs @@ -20,7 +20,7 @@ use proxy_wasm::types::*; use std::time::Duration; #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] -use getrandom::getrandom; +use getrandom::fill; proxy_wasm::main! {{ proxy_wasm::set_log_level(LogLevel::Trace); @@ -47,7 +47,7 @@ impl RootContext for HelloWorld { } else { let now: DateTime = Utc::now(); let mut buf = [0u8; 1]; - getrandom(&mut buf).unwrap(); + fill(&mut buf).unwrap(); info!("It's {}, your lucky number is {}.", now, buf[0]); } } From 5bd7296c19f02659790bef042897e30ccd1d3817 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 10 Feb 2025 22:35:53 -0500 Subject: [PATCH 2/2] review: use getrandom:fill inline to improve readability. Signed-off-by: Piotr Sikora --- examples/hello_world/src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/hello_world/src/lib.rs b/examples/hello_world/src/lib.rs index 7b7cbee6..7a005819 100644 --- a/examples/hello_world/src/lib.rs +++ b/examples/hello_world/src/lib.rs @@ -19,9 +19,6 @@ use proxy_wasm::traits::*; use proxy_wasm::types::*; use std::time::Duration; -#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] -use getrandom::fill; - proxy_wasm::main! {{ proxy_wasm::set_log_level(LogLevel::Trace); proxy_wasm::set_root_context(|_| -> Box { Box::new(HelloWorld) }); @@ -47,7 +44,7 @@ impl RootContext for HelloWorld { } else { let now: DateTime = Utc::now(); let mut buf = [0u8; 1]; - fill(&mut buf).unwrap(); + getrandom::fill(&mut buf).unwrap(); info!("It's {}, your lucky number is {}.", now, buf[0]); } }