rand_os/
fuchsia.rs

1// Copyright 2018 Developers of the Rand project.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9//! Implementation for Fuchsia Zircon
10
11extern crate fuchsia_cprng;
12
13use rand_core::Error;
14use super::OsRngImpl;
15
16#[derive(Clone, Debug)]
17pub struct OsRng;
18
19impl OsRngImpl for OsRng {
20    fn new() -> Result<OsRng, Error> { Ok(OsRng) }
21
22    fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
23        fuchsia_cprng::cprng_draw(dest);
24        Ok(())
25    }
26
27    fn method_str(&self) -> &'static str { "cprng_draw" }
28}