From 171c88f3036d859acbb22ec347e9c35363926bad Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Mon, 17 Oct 2022 08:24:40 +0200 Subject: [PATCH] Move result structures to a more appropriate location --- rust/cli_player/src/client.rs | 2 +- rust/cli_player/src/main.rs | 2 +- rust/cli_player/src/ui_screens/game_screen.rs | 2 +- rust/sea_battle_backend/src/utils/mod.rs | 11 +---------- rust/sea_battle_backend/src/utils/res_utils.rs | 9 +++++++++ 5 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 rust/sea_battle_backend/src/utils/res_utils.rs diff --git a/rust/cli_player/src/client.rs b/rust/cli_player/src/client.rs index fe4a8ee..d70f401 100644 --- a/rust/cli_player/src/client.rs +++ b/rust/cli_player/src/client.rs @@ -6,7 +6,7 @@ use hyper_rustls::ConfigBuilderExt; use sea_battle_backend::data::GameRules; use sea_battle_backend::human_player_ws::{ClientMessage, ServerMessage}; use sea_battle_backend::server::{BotPlayQuery, PlayRandomQuery}; -use sea_battle_backend::utils::{boxed_error, Res}; +use sea_battle_backend::utils::res_utils::{boxed_error, Res}; use std::fmt::Display; use std::sync::mpsc::TryRecvError; use std::sync::{mpsc, Arc}; diff --git a/rust/cli_player/src/main.rs b/rust/cli_player/src/main.rs index ea79e98..5586499 100644 --- a/rust/cli_player/src/main.rs +++ b/rust/cli_player/src/main.rs @@ -23,7 +23,7 @@ use cli_player::ui_screens::select_play_mode_screen::{SelectPlayModeResult, Sele use cli_player::ui_screens::*; use sea_battle_backend::consts::{MAX_PLAYER_NAME_LENGTH, MIN_PLAYER_NAME_LENGTH}; use sea_battle_backend::data::GameRules; -use sea_battle_backend::utils::Res; +use sea_battle_backend::utils::res_utils::Res; /// Test code screens async fn run_dev( diff --git a/rust/cli_player/src/ui_screens/game_screen.rs b/rust/cli_player/src/ui_screens/game_screen.rs index da8d824..4d1dbe7 100644 --- a/rust/cli_player/src/ui_screens/game_screen.rs +++ b/rust/cli_player/src/ui_screens/game_screen.rs @@ -12,8 +12,8 @@ use tui::{Frame, Terminal}; use sea_battle_backend::data::{Coordinates, CurrentGameMapStatus, CurrentGameStatus}; use sea_battle_backend::human_player_ws::{ClientMessage, ServerMessage}; +use sea_battle_backend::utils::res_utils::Res; use sea_battle_backend::utils::time_utils::time; -use sea_battle_backend::utils::Res; use crate::client::Client; use crate::constants::*; diff --git a/rust/sea_battle_backend/src/utils/mod.rs b/rust/sea_battle_backend/src/utils/mod.rs index 579e370..0dfef1d 100644 --- a/rust/sea_battle_backend/src/utils/mod.rs +++ b/rust/sea_battle_backend/src/utils/mod.rs @@ -1,13 +1,4 @@ -use std::error::Error; -use std::fmt::Display; -use std::io::ErrorKind; - pub mod network_utils; +pub mod res_utils; pub mod string_utils; pub mod time_utils; - -pub type Res = Result>; - -pub fn boxed_error(msg: D) -> Box { - Box::new(std::io::Error::new(ErrorKind::Other, msg.to_string())) -} diff --git a/rust/sea_battle_backend/src/utils/res_utils.rs b/rust/sea_battle_backend/src/utils/res_utils.rs new file mode 100644 index 0000000..b560606 --- /dev/null +++ b/rust/sea_battle_backend/src/utils/res_utils.rs @@ -0,0 +1,9 @@ +use std::error::Error; +use std::fmt::Display; +use std::io::ErrorKind; + +pub type Res = Result>; + +pub fn boxed_error(msg: D) -> Box { + Box::new(std::io::Error::new(ErrorKind::Other, msg.to_string())) +}