File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " rand"
3
- version = " 0.3.15 "
3
+ version = " 0.3.16 "
4
4
authors = [" The Rust Project Developers" ]
5
5
license = " MIT/Apache-2.0"
6
6
readme = " README.md"
@@ -25,3 +25,6 @@ log = "0.3.0"
25
25
26
26
[workspace ]
27
27
members = [" rand-derive" ]
28
+
29
+ [target .'cfg(target_os = "fuchsia")' .dependencies ]
30
+ magenta = " ^0.1.1"
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ fn next_u64(mut fill_buf: &mut FnMut(&mut [u8])) -> u64 {
68
68
#[ cfg( all( unix, not( target_os = "ios" ) ,
69
69
not( target_os = "nacl" ) ,
70
70
not( target_os = "freebsd" ) ,
71
+ not( target_os = "fuchsia" ) ,
71
72
not( target_os = "openbsd" ) ,
72
73
not( target_os = "redox" ) ) ) ]
73
74
mod imp {
@@ -380,6 +381,45 @@ mod imp {
380
381
}
381
382
}
382
383
384
+ #[ cfg( target_os = "fuchsia" ) ]
385
+ mod imp {
386
+ extern crate magenta;
387
+
388
+ use std:: io;
389
+ use Rng ;
390
+
391
+ use super :: { next_u32, next_u64} ;
392
+
393
+ #[ derive( Debug ) ]
394
+ pub struct OsRng ;
395
+
396
+ impl OsRng {
397
+ pub fn new ( ) -> io:: Result < OsRng > {
398
+ Ok ( OsRng )
399
+ }
400
+ }
401
+
402
+ impl Rng for OsRng {
403
+ fn next_u32 ( & mut self ) -> u32 {
404
+ next_u32 ( & mut |v| self . fill_bytes ( v) )
405
+ }
406
+ fn next_u64 ( & mut self ) -> u64 {
407
+ next_u64 ( & mut |v| self . fill_bytes ( v) )
408
+ }
409
+ fn fill_bytes ( & mut self , v : & mut [ u8 ] ) {
410
+ for s in v. chunks_mut ( magenta:: MX_CPRNG_DRAW_MAX_LEN ) {
411
+ let mut filled = 0 ;
412
+ while filled < s. len ( ) {
413
+ match magenta:: cprng_draw ( & mut s[ filled..] ) {
414
+ Ok ( actual) => filled += actual,
415
+ Err ( e) => panic ! ( "cprng_draw failed: {:?}" , e) ,
416
+ } ;
417
+ }
418
+ }
419
+ }
420
+ }
421
+ }
422
+
383
423
#[ cfg( windows) ]
384
424
mod imp {
385
425
use std:: io;
You can’t perform that action at this time.
0 commit comments