diff --git a/cli/Cargo.toml b/cli/Cargo.toml index f2c3eaf..91c5432 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -7,4 +7,4 @@ authors = ["James ", "Ronan ", "Charles This struct is used to parse the command line arguments -/// +/// /// ## Example -/// +/// /// ```sh /// worker -H 192.168.1.0 -P 3000 -N my_group_name /// ``` #[derive(Parser, Debug)] pub struct CliArgs { - #[clap( - short = 'H', - long = "hostname", - default_value = "localhost" - )] + #[clap(short = 'H', long = "hostname", default_value = "localhost")] pub hostname: String, - #[clap( - short = 'P', - long = "port", - default_value = "8787" - )] + #[clap(short = 'P', long = "port", default_value = "8787")] pub port: u16, - #[clap( - short = 'N', - long = "name", - default_value = "worker" - )] + #[clap(short = 'N', long = "name", default_value = "worker")] pub worker_name: String, -} \ No newline at end of file +} diff --git a/client/src/main.rs b/client/src/main.rs index a3fa476..e870a2b 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -6,6 +6,8 @@ use std::io; use crate::image::open_image; use crate::julia::generate_julia_set; +use cli::parser::{CliArgs, Parser}; +use server::services::{connect::connect, reader::read_message}; use shared::types::filesystem::FileExtension; use shared::types::fractal_descriptor::FractalType::Julia; use shared::types::fractal_descriptor::{FractalDescriptor, JuliaDescriptor}; @@ -15,12 +17,9 @@ use shared::types::range::Range; use shared::types::u8data::U8Data; use shared::types::{complex::Complex, resolution::Resolution}; use shared::utils::filesystem::{get_dir_path_buf, get_extension_str, get_file_path}; -use cli::parser::{CliArgs, Parser}; -use server::services::{reader::read_message, connect::connect}; - fn main() -> io::Result<()> { - let args : CliArgs = CliArgs::parse(); + let args: CliArgs = CliArgs::parse(); let stream = connect(format!("{}:{}", args.hostname, args.port).as_str())?; let message = read_message(stream); println!("{}", message); diff --git a/client/src/mod.rs b/client/src/mod.rs index 2417cba..c3c410d 100644 --- a/client/src/mod.rs +++ b/client/src/mod.rs @@ -1,3 +1,3 @@ -pub mod networking; pub mod image; pub mod julia; +pub mod networking; diff --git a/client/src/networking.rs b/client/src/networking.rs index e69de29..8b13789 100644 --- a/client/src/networking.rs +++ b/client/src/networking.rs @@ -0,0 +1 @@ + diff --git a/server/src/services/mod.rs b/server/src/services/mod.rs index f0e1bbd..83fb340 100644 --- a/server/src/services/mod.rs +++ b/server/src/services/mod.rs @@ -1,3 +1,3 @@ pub mod connect; +pub mod reader; pub mod write; -pub mod reader; \ No newline at end of file diff --git a/server/src/services/reader.rs b/server/src/services/reader.rs index cf58c15..d05e7bf 100644 --- a/server/src/services/reader.rs +++ b/server/src/services/reader.rs @@ -1,4 +1,4 @@ -use std::{net::TcpStream, io::Read}; +use std::{io::Read, net::TcpStream}; /// Read a message from a TCP stream. /// @@ -20,11 +20,11 @@ use std::{net::TcpStream, io::Read}; /// ```no_run /// use std::net::{TcpListener, TcpStream}; /// use server::services::reader::read_message; -/// +/// /// let listener = TcpListener::bind("127.0.0.1:0").unwrap(); /// let address = listener.local_addr().unwrap(); /// let mut stream = TcpStream::connect(address).unwrap(); -/// +/// /// let message = read_message(stream); /// println!("Received message: {}", message); /// ``` diff --git a/server/src/services/write.rs b/server/src/services/write.rs index 0a97ac3..861af6b 100644 --- a/server/src/services/write.rs +++ b/server/src/services/write.rs @@ -12,17 +12,17 @@ use std::net::TcpStream; /// # Return /// /// * `Result` - TcpStream -/// +/// /// # Example -/// +/// /// ```no_run /// use std::net::TcpStream; /// use server::services::write::write; -/// +/// /// let stream = TcpStream::connect("localhost:8787").unwrap(); /// let stream = write(stream, "Hello world!").unwrap(); /// ``` -/// +/// pub fn write(mut stream: TcpStream, message: &str) -> Result { stream.write(format!("${}", message).as_bytes())?;