-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add trait for StatusBytes and allow lazyly configuring the initialization of the RNG #26
Conversation
src/admin.rs
Outdated
/// Trait indicating that a value can be used as a status | ||
pub trait StatusBytes: AsRef<[u8]> { | ||
// Set the flag indicating that the random generator could properly be created (`false`) or not (`true`) | ||
fn set_random_error(&mut self, value: bool); | ||
// Get the flag indicating that the random generator could properly be created (`false`) or not (`true`) | ||
fn get_random_error(&self) -> bool; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be easier to only serialize on demand so we don’t need to parse and modify the bytes representation in the runner.
/// Trait indicating that a value can be used as a status | |
pub trait StatusBytes: AsRef<[u8]> { | |
// Set the flag indicating that the random generator could properly be created (`false`) or not (`true`) | |
fn set_random_error(&mut self, value: bool); | |
// Get the flag indicating that the random generator could properly be created (`false`) or not (`true`) | |
fn get_random_error(&self) -> bool; | |
} | |
/// Trait indicating that a value can be used as a status | |
pub trait Status { | |
// Returns the flag indicating that the random generator could properly be created (`false`) or not (`true`) | |
fn random_error(&mut self, value: bool) -> &mut Option<bool>; | |
// Writes the byte representation of this status value to a vec. | |
fn serialize_bytes<const N: usize>(&self, v: &mut Vec<u8, N>); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I were to do this this way I would probably do it with
pub trait Status {
type Serialized: AsRef<[u8]>;
fn serialize(&self) -> Self::Serialized;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d rather avoid the de-/serialization round trips required for get_random_error
/set_random_error
, otherwise LGTM.
189d6a3
to
914da07
Compare
No description provided.