#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Clock(pub bool);
impl std::ops::Deref for Clock {
type Target = bool;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl std::ops::DerefMut for Clock {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Binary(pub Vec<u8>);
impl std::ops::Deref for Binary {
type Target = [u8];
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl std::ops::DerefMut for Binary {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
pub trait InitializeFromStart<T> {
fn set_from_start(&mut self, value: T);
}
impl<T> InitializeFromStart<T> for T {
fn set_from_start(&mut self, value: T) {
*self = value;
}
}
impl InitializeFromStart<&[u8]> for Binary {
fn set_from_start(&mut self, value: &[u8]) {
*self = Binary(value.to_vec());
}
}
impl<const N: usize> InitializeFromStart<&[u8; N]> for Binary {
fn set_from_start(&mut self, value: &[u8; N]) {
*self = Binary(value.to_vec());
}
}