@@ -46,6 +46,7 @@ rng.generate_block(&mut buffer).expect("Failed to generate a block");
4646
4747use crate :: sys;
4848use core:: mem:: { size_of_val, MaybeUninit } ;
49+ use num_traits:: PrimInt ;
4950
5051/// A cryptographically secure random number generator based on the wolfSSL
5152/// library.
@@ -127,7 +128,7 @@ impl RNG {
127128 ///
128129 /// A Result which is Ok(RNG) on success or an Err containing the wolfSSL
129130 /// library return code on failure.
130- pub fn new_with_nonce < T > ( nonce : & mut [ T ] ) -> Result < Self , i32 > {
131+ pub fn new_with_nonce < T : PrimInt > ( nonce : & mut [ T ] ) -> Result < Self , i32 > {
131132 RNG :: new_with_nonce_ex ( nonce, None , None )
132133 }
133134
@@ -146,7 +147,7 @@ impl RNG {
146147 ///
147148 /// A Result which is Ok(RNG) on success or an Err containing the wolfSSL
148149 /// library return code on failure.
149- pub fn new_with_nonce_ex < T > ( nonce : & mut [ T ] , heap : Option < * mut core:: ffi:: c_void > , dev_id : Option < i32 > ) -> Result < Self , i32 > {
150+ pub fn new_with_nonce_ex < T : PrimInt > ( nonce : & mut [ T ] , heap : Option < * mut core:: ffi:: c_void > , dev_id : Option < i32 > ) -> Result < Self , i32 > {
150151 #[ cfg( fips) ]
151152 {
152153 let rc = unsafe {
@@ -338,7 +339,7 @@ impl RNG {
338339 ///
339340 /// A `Result` which is `Ok(())` on success or an `Err` with the wolfssl
340341 /// library return code on failure.
341- pub fn generate_block < T > ( & mut self , buf : & mut [ T ] ) -> Result < ( ) , i32 > {
342+ pub fn generate_block < T : PrimInt > ( & mut self , buf : & mut [ T ] ) -> Result < ( ) , i32 > {
342343 let ptr = buf. as_mut_ptr ( ) as * mut u8 ;
343344 let size = crate :: buffer_len_to_u32 ( size_of_val ( buf) ) ?;
344345 let rc = unsafe { sys:: wc_RNG_GenerateBlock ( & mut self . wc_rng , ptr, size) } ;
0 commit comments