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 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;
tile
};

View file

@ -85,7 +85,10 @@ pub struct TileData {
#[async_trait]
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)]
@ -113,7 +116,12 @@ pub struct 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 {
sender: BlockSender {
sender_id,
@ -124,8 +132,6 @@ impl Tile {
}
}
pub fn spawn(mut self) -> JoinHandle<Result<(), Box<dyn std::error::Error + Send + Sync>>> {
tokio::spawn(async move {
self.module.run(&mut self.sender).await
})
tokio::spawn(async move { self.module.run(&mut self.sender).await })
}
}

View file

@ -14,7 +14,10 @@ impl Hostname {
#[async_trait]
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();
File::open("/proc/sys/kernel/hostname")
.await?

View file

@ -16,7 +16,10 @@ impl Load {
#[async_trait]
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));
loop {
timer.tick().await;

View file

@ -54,7 +54,10 @@ impl Memory {
#[async_trait]
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 raw = [0u8; 256];
loop {

View file

@ -37,7 +37,10 @@ impl Default for Time {
#[async_trait]
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();
loop {
sender.send(self.send_time(time)).await?;