// internal static \u0024ArrayType\u0024\u0024\u0024BY08E \u003FA0x171ed149\u002E\u003FprevData\u0040\u003F1\u003F\u003FSetLEDBehavior\u0040CVGAAdaptor\u0040\u0040UEAA_NEEEEEEEEE\u0040Z\u00404PAEA;
// public static __FnPtr<_ctl_result_t (_ctl_init_args_t*, _ctl_api_handle_t**)> __m2mep\u0040\u003FctlInit\u0040\u0040\u0024\u0024J0YA\u003FAW4_ctl_result_t\u0040\u0040PEAU_ctl_init_args_t\u0040\u0040PEAPEAU_ctl_api_handle_t\u0040\u0040\u0040Z;
+use log::error;
+
use std::{
io::prelude::*,
net::TcpStream,
}
impl A770 {
- pub fn new() -> Self {
- A770 {
- process: Command::new(r"IntelOC.exe")
- .spawn()
- .expect("failed to execute process"),
- stream: TcpStream::connect("127.0.0.1:6577").unwrap(),
- }
+ pub fn new() -> anyhow::Result<Self> {
+ Ok(A770 {
+ process: Command::new(r"IntelOC.exe").spawn()?,
+ stream: TcpStream::connect("127.0.0.1:6577")?,
+ })
}
- pub fn set_color(&mut self, r: u8, g: u8, b: u8) {
+ pub fn set_color(&mut self, r: u8, g: u8, b: u8) -> anyhow::Result<()> {
let buffer: [u8; 3] = [r, g, b];
- self.stream.write(&buffer).unwrap();
+ self.stream.write(&buffer).map(|_| ())?;
+ Ok(())
}
}
impl Drop for A770 {
fn drop(&mut self) {
- self.process.kill().unwrap();
- self.process.try_wait().unwrap();
+ if let Err(error) = self.process.kill().and(self.process.try_wait()) {
+ error!("Unable to kill the child process: {:?}", error);
+ }
}
}