Implementing hyper ws and types
This commit is contained in:
+13
-2
@@ -2,6 +2,7 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub mod general;
|
||||
mod hyper_types;
|
||||
pub mod plugin;
|
||||
pub mod terminal;
|
||||
pub mod units;
|
||||
@@ -9,8 +10,8 @@ pub mod units;
|
||||
pub mod prelude {
|
||||
pub use crate::PulseWire;
|
||||
pub use crate::general::*;
|
||||
pub use crate::server_path;
|
||||
pub use crate::plugin::*;
|
||||
pub use crate::server_path;
|
||||
pub use crate::terminal::*;
|
||||
pub use crate::units::*;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ 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()
|
||||
vec![1].into_iter().chain(v.to_com()).collect()
|
||||
} else {
|
||||
vec![0]
|
||||
}
|
||||
@@ -90,6 +91,16 @@ impl PulseWire for String {
|
||||
}
|
||||
}
|
||||
|
||||
impl PulseWire for bool {
|
||||
fn to_com(&self) -> Vec<u8> {
|
||||
if *self { vec![1] } else { vec![0] }
|
||||
}
|
||||
|
||||
fn from_com(com: &mut Vec<u8>) -> Self {
|
||||
com[0] > 0
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! int_com {
|
||||
($t:ty) => {
|
||||
impl $crate::PulseWire for $t {
|
||||
|
||||
Reference in New Issue
Block a user