diff --git a/src/config.rs b/src/config.rs index f8cc368..11a8786 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,7 +1,3 @@ -extern crate serde; -extern crate serde_derive; -extern crate serde_json; - use std::fs::File; use std::io::Read; use std::path::Path; @@ -47,9 +43,13 @@ impl Configuration { let response = get_request(&request); match response { Ok(res) => { - let document = Document::from_read(res).unwrap(); - let next = document.find(Name("app")).next().unwrap(); - next.text().to_string() + let document = Document::from_read(res) + .unwrap(); + let next = document.find(Name("app")) + .next() + .unwrap(); + next.text() + .to_string() } Err(_) => "_".to_string() } @@ -65,9 +65,13 @@ impl Configuration { let response = get_request(&request); match response { Ok(res) => { - let document = Document::from_read(res).unwrap(); - let next = document.find(Name("power-mode")).next().unwrap(); - next.text().to_string() + let document = Document::from_read(res) + .unwrap(); + let next = document.find(Name("power-mode")) + .next() + .unwrap(); + next.text() + .to_string() } Err(_) => "_".to_string() } diff --git a/src/main.rs b/src/main.rs index 7b4915c..a72fd62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,3 @@ -// external crates getting imported -extern crate reqwest; -extern crate select; -extern crate serde; -extern crate serde_derive; -extern crate serde_json; - // std lib imports use std::{thread, time}; @@ -21,7 +14,8 @@ mod generate; const NUM_LEDS: usize = 150; fn main() { - let spi = Spi::new(Bus::Spi0, SlaveSelect::Ss0, 3_000_000, Mode::Mode0).unwrap(); + let spi = Spi::new(Bus::Spi0, SlaveSelect::Ss0, 3_000_000, Mode::Mode0) + .unwrap(); let mut ws = Ws2812::new(spi); let mut configuration = config::init_config(); let mut is_headless: bool = false; @@ -45,7 +39,8 @@ fn main() { data[i] = color; } - ws.write(brightness(data.iter().cloned(), 32)).unwrap(); + ws.write(brightness(data.iter().cloned(), 32)) + .unwrap(); } }, app::TVPower::On => { @@ -59,24 +54,29 @@ fn main() { match activeapp { app::ActiveApp::Roku => { let data = change_color(&255, &0, &255); - ws.write(brightness(data.iter().cloned(), 10)).unwrap(); + ws.write(brightness(data.iter().cloned(), 10)) + .unwrap(); }, app::ActiveApp::Hulu => { let data = change_color(&51, &255, &85); - ws.write(brightness(data.iter().cloned(), 32)).unwrap(); + ws.write(brightness(data.iter().cloned(), 32)) + .unwrap(); }, app::ActiveApp::Netflix => { let data = change_color(&255, &77, &77); - ws.write(brightness(data.iter().cloned(), 32)).unwrap(); + ws.write(brightness(data.iter().cloned(), 32)) + .unwrap(); }, app::ActiveApp::AmazonPrime => println!("The light are light blue!"), app::ActiveApp::Spotify => { let data = change_color(&51, &255, &85); - ws.write(brightness(data.iter().cloned(), 32)).unwrap(); + ws.write(brightness(data.iter().cloned(), 32)) + .unwrap(); }, app::ActiveApp::Plex => { let data = change_color(&255, &187, &51); - ws.write(brightness(data.iter().cloned(), 32)).unwrap(); + ws.write(brightness(data.iter().cloned(), 32)) + .unwrap(); }, _ => println!("We don't know what app is running right now..."), }