Skip to content

Added new (yet unproven) blocking Read trait for a rngs #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/blocking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pub mod delay;
pub mod i2c;
pub mod serial;
pub mod spi;
pub mod rng;
17 changes: 17 additions & 0 deletions src/blocking/rng.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! Blocking hardware random number generator

/// Blocking read
#[cfg(feature = "unproven")]
pub trait Read {
/// Error type
type Error;

/// Reads enough bytes from hardware random number generator to fill `buffer`
///
/// If any error is encountered then this function immediately returns. The contents of buf are
/// unspecified in this case.
///
/// If this function returns an error, it is unspecified how many bytes it has read, but it
/// will never read more than would be necessary to completely fill the buffer.
fn read(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error>;
}
2 changes: 2 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub use ::blocking::spi::{
Transfer as _embedded_hal_blocking_spi_Transfer,
Write as _embedded_hal_blocking_spi_Write,
};
#[cfg(feature = "unproven")]
pub use ::blocking::rng::Read as _embedded_hal_blocking_rng_Read;
pub use ::digital::OutputPin as _embedded_hal_digital_OutputPin;
#[cfg(feature = "unproven")]
pub use ::digital::InputPin as _embedded_hal_digital_InputPin;
Expand Down