|
6 | 6 | // option. This file may not be copied, modified, or distributed |
7 | 7 | // except according to those terms. |
8 | 8 |
|
9 | | -use core::fmt::Debug; |
| 9 | +use core::{convert::Infallible, fmt::Debug}; |
10 | 10 |
|
11 | 11 | use rand_core::{ |
12 | | - CryptoRng, RngCore, SeedableRng, |
| 12 | + SeedableRng, TryCryptoRng, TryRngCore, |
13 | 13 | block::{BlockRng, CryptoGenerator, Generator}, |
14 | 14 | }; |
15 | 15 |
|
@@ -291,22 +291,25 @@ macro_rules! impl_chacha_rng { |
291 | 291 | } |
292 | 292 | } |
293 | 293 | } |
294 | | - impl RngCore for $ChaChaXRng { |
| 294 | + impl TryRngCore for $ChaChaXRng { |
| 295 | + type Error = Infallible; |
| 296 | + |
295 | 297 | #[inline] |
296 | | - fn next_u32(&mut self) -> u32 { |
297 | | - self.core.next_word() |
| 298 | + fn try_next_u32(&mut self) -> Result<u32, Self::Error> { |
| 299 | + Ok(self.core.next_word()) |
298 | 300 | } |
299 | 301 | #[inline] |
300 | | - fn next_u64(&mut self) -> u64 { |
301 | | - self.core.next_u64_from_u32() |
| 302 | + fn try_next_u64(&mut self) -> Result<u64, Self::Error> { |
| 303 | + Ok(self.core.next_u64_from_u32()) |
302 | 304 | } |
303 | 305 | #[inline] |
304 | | - fn fill_bytes(&mut self, dest: &mut [u8]) { |
305 | | - self.core.fill_bytes(dest) |
| 306 | + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error> { |
| 307 | + self.core.fill_bytes(dest); |
| 308 | + Ok(()) |
306 | 309 | } |
307 | 310 | } |
308 | 311 | impl CryptoGenerator for $ChaChaXCore {} |
309 | | - impl CryptoRng for $ChaChaXRng {} |
| 312 | + impl TryCryptoRng for $ChaChaXRng {} |
310 | 313 |
|
311 | 314 | #[cfg(feature = "zeroize")] |
312 | 315 | impl ZeroizeOnDrop for $ChaChaXCore {} |
|
0 commit comments