Strategy messaging
This commit is contained in:
@@ -52,6 +52,24 @@ impl<T: PulseWire> PulseWire for Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: PulseWire> PulseWire for Option<T> {
|
||||
fn to_com(&self) -> Vec<u8> {
|
||||
if let Some(v) = self {
|
||||
v.to_com()
|
||||
} else {
|
||||
vec![0]
|
||||
}
|
||||
}
|
||||
|
||||
fn from_com(com: &mut Vec<u8>) -> Self {
|
||||
if com[0] > 0 {
|
||||
Some(T::from_com(com))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PulseWire for String {
|
||||
fn to_com(&self) -> Vec<u8> {
|
||||
let bytes = self.as_bytes();
|
||||
|
||||
Reference in New Issue
Block a user