Skip to content

Commit

Permalink
🎨🚨 cargo fix + cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
adia-dev committed Jan 7, 2024
1 parent eedaa06 commit c30de22
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 27 deletions.
3 changes: 1 addition & 2 deletions cli/src/commands/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use clap::Parser;

#[derive(Parser, Debug)]
pub struct ServerCommand {
}
pub struct ServerCommand {}
4 changes: 2 additions & 2 deletions shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod models;
pub mod logger;
pub mod env;
pub mod logger;
pub mod models;
pub mod networking;

pub fn add(left: usize, right: usize) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion shared/src/models/fractal/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod fractal;
pub mod fractal_descriptor;
pub mod iterated_sin_z;
pub mod julia;
pub mod mandelbrot;
pub mod newton_raphson_3;
pub mod newton_raphson_4;
pub mod iterated_sin_z;
11 changes: 9 additions & 2 deletions shared/src/models/fragments/fragment_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::models::{
pixel::pixel_data::PixelData, range::Range, resolution::Resolution, u8_data::U8Data,
};

use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

use super::fragment::Fragment;
#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -14,7 +14,14 @@ pub struct FragmentResult {
}

impl FragmentResult {
pub fn new(id: U8Data, resolution: Resolution, range: Range, pixels: PixelData) -> Self { Self { id, resolution, range, pixels } }
pub fn new(id: U8Data, resolution: Resolution, range: Range, pixels: PixelData) -> Self {
Self {
id,
resolution,
range,
pixels,
}
}
}

impl Fragment for FragmentResult {
Expand Down
8 changes: 3 additions & 5 deletions shared/src/models/fragments/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

pub mod fragment_task;
pub mod fragment_result;
pub mod fragment_request;
pub mod fragment;

pub mod fragment_request;
pub mod fragment_result;
pub mod fragment_task;
4 changes: 2 additions & 2 deletions shared/src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod fractal;
pub mod fragments;
pub mod pixel;
pub mod point;
pub mod range;
pub mod resolution;
pub mod u8_data;
pub mod fragments;
pub mod fractal;
1 change: 0 additions & 1 deletion shared/src/models/pixel/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod pixel_data;
pub mod pixel_intensity;

6 changes: 4 additions & 2 deletions shared/src/models/pixel/pixel_data.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PixelData {
pub offset: u32,
pub count: u32,
}

impl PixelData {
pub fn new(offset: u32, count: u32) -> Self { Self { offset, count } }
pub fn new(offset: u32, count: u32) -> Self {
Self { offset, count }
}
}
2 changes: 1 addition & 1 deletion shared/src/models/point/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct Point {
pub x: f64,
Expand Down
2 changes: 1 addition & 1 deletion shared/src/models/range/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::point::Point;

use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct Range {
pub min: Point,
Expand Down
2 changes: 1 addition & 1 deletion shared/src/models/resolution/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct Resolution {
pub nx: u16,
Expand Down
2 changes: 1 addition & 1 deletion shared/src/models/u8_data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct U8Data {
pub offset: u32,
Expand Down
2 changes: 1 addition & 1 deletion shared/src/networking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pub mod result;
pub mod server;
pub mod worker;

use std::io;
use log::debug;
use std::io;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;

Expand Down
8 changes: 3 additions & 5 deletions worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ use shared::{
send_request, send_result, worker::Worker,
},
};
use tokio::{
io::AsyncWriteExt,
net::TcpStream,
};
use tokio::{io::AsyncWriteExt, net::TcpStream};

// #[tokio::main]
// async fn main() {
Expand Down Expand Up @@ -135,7 +132,8 @@ async fn read_fragment_task(

async fn send_fragment_request(stream: &mut TcpStream, worker: &Worker) -> NetworkingResult<()> {
info!("Worker launched: {}", worker.name);
let request = FragmentRequest::new(worker.name.to_owned(), worker.maximal_work_load).to_json()?;
let request =
FragmentRequest::new(worker.name.to_owned(), worker.maximal_work_load).to_json()?;
let serialized_fragment_request = serde_json::to_string(&request)?;
let serialized_fragment_request_bytes = serialized_fragment_request.as_bytes();
debug!(
Expand Down

0 comments on commit c30de22

Please sign in to comment.