Run rust fmt

This commit is contained in:
Skye Jensen 2020-06-03 17:07:06 -04:00
parent 187aa4e695
commit f08d1bdc7d
6 changed files with 34 additions and 11 deletions

View file

@ -21,7 +21,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut index = 0usize; let mut index = 0usize;
let mut wrap = |module| { let mut wrap = |module| {
let tile = tile::Tile::new(index, sender.clone(), Uuid::new_v4().to_string().into(), module); let tile = tile::Tile::new(
index,
sender.clone(),
Uuid::new_v4().to_string().into(),
module,
);
index += 1; index += 1;
tile tile
}; };

View file

@ -85,7 +85,10 @@ pub struct TileData {
#[async_trait] #[async_trait]
pub trait TileModule: Send + std::fmt::Debug { pub trait TileModule: Send + std::fmt::Debug {
async fn run(&mut self, sender: &mut BlockSender) -> Result<(), Box<dyn std::error::Error + Send + Sync>>; async fn run(
&mut self,
sender: &mut BlockSender,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>;
} }
#[derive(Debug)] #[derive(Debug)]
@ -113,7 +116,12 @@ pub struct Tile {
} }
impl Tile { impl Tile {
pub fn new(sender_id: usize, sender: Sender<TileData>, instance: Arc<str>, module: Box<dyn TileModule>) -> Self { pub fn new(
sender_id: usize,
sender: Sender<TileData>,
instance: Arc<str>,
module: Box<dyn TileModule>,
) -> Self {
Tile { Tile {
sender: BlockSender { sender: BlockSender {
sender_id, sender_id,
@ -124,8 +132,6 @@ impl Tile {
} }
} }
pub fn spawn(mut self) -> JoinHandle<Result<(), Box<dyn std::error::Error + Send + Sync>>> { pub fn spawn(mut self) -> JoinHandle<Result<(), Box<dyn std::error::Error + Send + Sync>>> {
tokio::spawn(async move { tokio::spawn(async move { self.module.run(&mut self.sender).await })
self.module.run(&mut self.sender).await
})
} }
} }

View file

@ -14,7 +14,10 @@ impl Hostname {
#[async_trait] #[async_trait]
impl TileModule for Hostname { impl TileModule for Hostname {
async fn run(&mut self, sender: &mut BlockSender) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { async fn run(
&mut self,
sender: &mut BlockSender,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let mut raw = String::new(); let mut raw = String::new();
File::open("/proc/sys/kernel/hostname") File::open("/proc/sys/kernel/hostname")
.await? .await?

View file

@ -16,7 +16,10 @@ impl Load {
#[async_trait] #[async_trait]
impl TileModule for Load { impl TileModule for Load {
async fn run(&mut self, sender: &mut BlockSender) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { async fn run(
&mut self,
sender: &mut BlockSender,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let mut timer = interval(Duration::from_secs(5)); let mut timer = interval(Duration::from_secs(5));
loop { loop {
timer.tick().await; timer.tick().await;

View file

@ -54,7 +54,10 @@ impl Memory {
#[async_trait] #[async_trait]
impl TileModule for Memory { impl TileModule for Memory {
async fn run(&mut self, sender: &mut BlockSender) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { async fn run(
&mut self,
sender: &mut BlockSender,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let mut timer = interval(Duration::from_secs(5)); let mut timer = interval(Duration::from_secs(5));
let mut raw = [0u8; 256]; let mut raw = [0u8; 256];
loop { loop {

View file

@ -37,7 +37,10 @@ impl Default for Time {
#[async_trait] #[async_trait]
impl TileModule for Time { impl TileModule for Time {
async fn run(&mut self, sender: &mut BlockSender) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { async fn run(
&mut self,
sender: &mut BlockSender,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let mut time = Local::now(); let mut time = Local::now();
loop { loop {
sender.send(self.send_time(time)).await?; sender.send(self.send_time(time)).await?;