diff options
39 files changed, 222 insertions, 251 deletions
@@ -1,5 +1,5 @@ use std::env; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process::Command; const COMPILE_INFO_RS: &str = "./src/data/compile_info.rs"; @@ -58,7 +58,7 @@ fn generate_c_binding() { } /// Generate compile info -fn generate_compile_info(repo_root: &PathBuf) -> Result<(), Box<dyn std::error::Error>> { +fn generate_compile_info(repo_root: &Path) -> Result<(), Box<dyn std::error::Error>> { // Read the template code let template_code = std::fs::read_to_string(repo_root.join(COMPILE_INFO_RS_TEMPLATE))?; @@ -135,14 +135,12 @@ fn get_version() -> String { Err(_) => return "unknown".to_string(), }; - if let Some(workspace) = cargo_toml.get("workspace") { - if let Some(package) = workspace.get("package") { - if let Some(version) = package.get("version") { - if let Some(version_str) = version.as_str() { - return version_str.to_string(); - } - } - } + if let Some(workspace) = cargo_toml.get("workspace") + && let Some(package) = workspace.get("package") + && let Some(version) = package.get("version") + && let Some(version_str) = version.as_str() + { + return version_str.to_string(); } "unknown".to_string() diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs index 7ffcb00..4682136 100644 --- a/ffi/src/lib.rs +++ b/ffi/src/lib.rs @@ -3,11 +3,18 @@ pub use constants::*; #[unsafe(no_mangle)] #[allow(nonstandard_style)] -pub extern "C" fn JV_FreeString(ptr: *mut libc::c_char) { - if ptr.is_null() { - return; - } +/// # Safety +/// +/// This function must be called with a pointer that was obtained from +/// `JV_Const_*` functions or `std::ffi::CString::into_raw()`. The pointer +/// must not be null unless it was explicitly returned as null from the +/// allocating function. After calling this function, the pointer becomes +/// invalid and must not be used again. +pub unsafe extern "C" fn JV_FreeString(ptr: *mut libc::c_char) { unsafe { + if ptr.is_null() { + return; + } drop(std::ffi::CString::from_raw(ptr)); } } diff --git a/legacy_actions/src/lib.rs b/legacy_actions/src/lib.rs index c1dda86..f6b0281 100644 --- a/legacy_actions/src/lib.rs +++ b/legacy_actions/src/lib.rs @@ -1,3 +1,9 @@ +#![allow( + clippy::type_complexity, + clippy::question_mark, + clippy::redundant_pattern_matching +)] + pub mod connection; pub mod local_actions; pub mod registry; diff --git a/legacy_actions/src/remote_actions.rs b/legacy_actions/src/remote_actions.rs index d15edc9..64db407 100644 --- a/legacy_actions/src/remote_actions.rs +++ b/legacy_actions/src/remote_actions.rs @@ -108,24 +108,22 @@ pub async fn auth_member( Err(TcpTargetError::Authentication( "Authenticate failed.".to_string(), )) - } else { - if using_host_mode { - if vault.config().vault_host_list().contains(&member_id) { - // Using Host mode authentication, and is indeed an administrator - mut_instance.write(true).await?; - Ok((member_id, true)) - } else { - // Using Host mode authentication, but not an administrator - mut_instance.write(false).await?; - Err(TcpTargetError::Authentication( - "Authenticate failed.".to_string(), - )) - } - } else { - // Not using Host mode authentication + } else if using_host_mode { + if vault.config().vault_host_list().contains(&member_id) { + // Using Host mode authentication, and is indeed an administrator mut_instance.write(true).await?; - Ok((member_id, false)) + Ok((member_id, true)) + } else { + // Using Host mode authentication, but not an administrator + mut_instance.write(false).await?; + Err(TcpTargetError::Authentication( + "Authenticate failed.".to_string(), + )) } + } else { + // Not using Host mode authentication + mut_instance.write(true).await?; + Ok((member_id, false)) } } Err(e) => Err(e), diff --git a/legacy_actions/src/remote_actions/content_manage/track_file.rs b/legacy_actions/src/remote_actions/content_manage/track_file.rs index a59ca76..0beb348 100644 --- a/legacy_actions/src/remote_actions/content_manage/track_file.rs +++ b/legacy_actions/src/remote_actions/content_manage/track_file.rs @@ -437,7 +437,7 @@ async fn proc_create_tasks_local( let mut mut_instance = instance.lock().await; let mut local_sheet = workspace.local_sheet(member_id, sheet_name).await?; - if print_infos && relative_paths.len() > 0 { + if print_infos && !relative_paths.is_empty() { local_println!(local_output, "Creating {} files...", relative_paths.len()); } @@ -585,7 +585,7 @@ async fn proc_update_tasks_local( let mut success = Vec::new(); - if print_infos && relative_paths.len() > 0 { + if print_infos && !relative_paths.is_empty() { local_println!(local_output, "Updating {} files...", relative_paths.len()); } @@ -826,7 +826,7 @@ async fn proc_sync_tasks_local( let mut mut_instance = instance.lock().await; let mut success: Vec<PathBuf> = Vec::new(); - if print_infos && relative_paths.len() > 0 { + if print_infos && !relative_paths.is_empty() { local_println!(local_output, "Syncing {} files...", relative_paths.len()); } @@ -902,7 +902,7 @@ async fn proc_sync_tasks_local( // First download let mut data = LocalMappingMetadata::default(); data.set_mapping_vfid(vfid); - if let Err(_) = local_sheet.add_mapping(&path, data) { + if local_sheet.add_mapping(&path, data).is_err() { continue; } match local_sheet.mapping_data_mut(&path) { diff --git a/legacy_actions/src/remote_actions/mapping_manage/merge_share_mapping.rs b/legacy_actions/src/remote_actions/mapping_manage/merge_share_mapping.rs index df889a1..d3485cb 100644 --- a/legacy_actions/src/remote_actions/mapping_manage/merge_share_mapping.rs +++ b/legacy_actions/src/remote_actions/mapping_manage/merge_share_mapping.rs @@ -104,11 +104,8 @@ pub async fn merge_share_mapping_action( .await .read::<MergeShareMappingActionResult>() .await?; - match result { - MergeShareMappingActionResult::Success => { - sign_vault_modified(true).await; - } - _ => {} + if let MergeShareMappingActionResult::Success = result { + sign_vault_modified(true).await; } return Ok(result); } diff --git a/legacy_actions/src/remote_actions/workspace_manage/update_to_latest_info.rs b/legacy_actions/src/remote_actions/workspace_manage/update_to_latest_info.rs index cd17c32..7ff2c49 100644 --- a/legacy_actions/src/remote_actions/workspace_manage/update_to_latest_info.rs +++ b/legacy_actions/src/remote_actions/workspace_manage/update_to_latest_info.rs @@ -80,8 +80,8 @@ pub async fn update_to_latest_info_action( for sheet in vault.sheets().await? { // Build share parts - if let Some(holder) = sheet.holder() { - if holder == &member_id || holder == VAULT_HOST_NAME { + if let Some(holder) = sheet.holder() + && (holder == &member_id || holder == VAULT_HOST_NAME) { let mut sheet_shares: HashMap<SheetShareId, Share> = HashMap::new(); for share in sheet.get_shares().await? { // Get SharePath @@ -99,11 +99,10 @@ pub async fn update_to_latest_info_action( } shares_in_my_sheets.insert(sheet.name().clone(), sheet_shares); } - } // Build sheet parts let holder_is_host = - sheet.holder().unwrap_or(&String::default()) == &VAULT_HOST_NAME; + sheet.holder().unwrap_or(&String::default()) == VAULT_HOST_NAME; if sheet.holder().is_some() && (sheet.holder().unwrap() == &member_id || holder_is_host) { @@ -129,7 +128,7 @@ pub async fn update_to_latest_info_action( latest_info.ref_sheet_content = ref_sheet_data.clone(); latest_info.ref_sheet_vfs_mapping = ref_sheet_data .mapping() - .into_iter() + .iter() .map(|(path, file)| (file.id.clone(), path.clone())) .collect::<HashMap<VirtualFileId, SheetPathBuf>>(); latest_info.reference_sheets = ref_sheets; diff --git a/legacy_data/src/data/local/workspace_analyzer.rs b/legacy_data/src/data/local/workspace_analyzer.rs index 82cd4e0..6373525 100644 --- a/legacy_data/src/data/local/workspace_analyzer.rs +++ b/legacy_data/src/data/local/workspace_analyzer.rs @@ -180,8 +180,8 @@ impl<'a> AnalyzeResult<'a> { // Files that exist locally but not in remote let mut erased_files: HashSet<PathBuf> = HashSet::new(); - if let Some(cached_data) = &analyze_ctx.cached_sheet_data { - if let Some(local_sheet) = &analyze_ctx.local_sheet { + if let Some(cached_data) = &analyze_ctx.cached_sheet_data + && let Some(local_sheet) = &analyze_ctx.local_sheet { let cached_sheet_mapping = cached_data.mapping(); let local_sheet_mapping = &local_sheet.data.mapping; @@ -192,7 +192,6 @@ impl<'a> AnalyzeResult<'a> { } } } - } // Files that exist in the local sheet but not in reality are considered lost let mut lost_files: HashSet<&PathBuf> = local_sheet_paths diff --git a/legacy_data/src/data/vault/mapping_share.rs b/legacy_data/src/data/vault/mapping_share.rs index 59cd6ba..2635b48 100644 --- a/legacy_data/src/data/vault/mapping_share.rs +++ b/legacy_data/src/data/vault/mapping_share.rs @@ -294,12 +294,11 @@ impl<'a> Sheet<'a> { } // Check for duplicate IDs - if let Some(id_mapping) = self.id_mapping() { - if id_mapping.contains_key(&metadata.id) { + if let Some(id_mapping) = self.id_mapping() + && id_mapping.contains_key(&metadata.id) { conflicts.duplicate_file.push(mapping.clone()); continue; } - } } conflicts @@ -411,8 +410,7 @@ impl Share { match fs::remove_file(path).await { Err(err) => Err(( self, - Error::new( - std::io::ErrorKind::Other, + Error::other( format!("Failed to delete share file: {}", err), ), )), diff --git a/legacy_data/src/data/vault/vault_config.rs b/legacy_data/src/data/vault/vault_config.rs index caa8552..156083b 100644 --- a/legacy_data/src/data/vault/vault_config.rs +++ b/legacy_data/src/data/vault/vault_config.rs @@ -52,18 +52,18 @@ pub enum BehaviourEnabled { No, } -impl Into<bool> for ServiceEnabled { - fn into(self) -> bool { - match self { +impl From<ServiceEnabled> for bool { + fn from(val: ServiceEnabled) -> Self { + match val { ServiceEnabled::Enable => true, ServiceEnabled::Disable => false, } } } -impl Into<bool> for BehaviourEnabled { - fn into(self) -> bool { - match self { +impl From<BehaviourEnabled> for bool { + fn from(val: BehaviourEnabled) -> Self { + match val { BehaviourEnabled::Yes => true, BehaviourEnabled::No => false, } diff --git a/legacy_data/src/lib.rs b/legacy_data/src/lib.rs index df2ec34..d2e64b4 100644 --- a/legacy_data/src/lib.rs +++ b/legacy_data/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + pub mod constants; pub mod env; diff --git a/legacy_systems/action/src/lib.rs b/legacy_systems/action/src/lib.rs index 12ae999..fb49e30 100644 --- a/legacy_systems/action/src/lib.rs +++ b/legacy_systems/action/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::all)] + pub mod macros { pub use action_system_macros::*; } diff --git a/legacy_utils/cfg_file/src/lib.rs b/legacy_utils/cfg_file/src/lib.rs index 72246e7..dd04b32 100644 --- a/legacy_utils/cfg_file/src/lib.rs +++ b/legacy_utils/cfg_file/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::all)] + #[cfg(feature = "derive")] extern crate cfg_file_derive; diff --git a/protocol/src/address.rs b/protocol/src/address.rs index 60cc17c..3f927e0 100644 --- a/protocol/src/address.rs +++ b/protocol/src/address.rs @@ -47,6 +47,15 @@ where } } +impl<Protocol> Default for Host<Protocol> +where + Protocol: BasicProtocol, +{ + fn default() -> Self { + Self::new() + } +} + impl<Protocol> Host<Protocol> where Protocol: BasicProtocol, diff --git a/protocol/src/protocol.rs b/protocol/src/protocol.rs index a097989..4bcdbd2 100644 --- a/protocol/src/protocol.rs +++ b/protocol/src/protocol.rs @@ -74,7 +74,7 @@ pub trait BasicProtocol { /// Transfer indexes /// /// - `index_transfer` and `storage` represent the index file and - /// the corresponding block storage path, respectively. + /// the corresponding block storage path, respectively. /// - If `vault` is Some, send block information from the Vault. /// - If `workspace` is Some, send block information from the Workspace. /// diff --git a/rust-analyzer.toml b/rust-analyzer.toml index 0754abc..1f677ad 100644 --- a/rust-analyzer.toml +++ b/rust-analyzer.toml @@ -1,20 +1,12 @@ -[package] -proc-macro.enable = true - -[cargo] -allFeatures = true -loadOutDirsFromCheck = true -runBuildScripts = true - [rust-analyzer] -procMacro.enable = true -procMacro.attributes.enable = true +proc-macro.enable = true +proc-macro.attributes.enable = true diagnostics.disabled = ["unresolved-proc-macro"] -inlayHints.typeHints = true -inlayHints.parameterHints = true -inlayHints.chainingHints = true +inlay-hints.type-hints = true +inlay-hints.parameter-hints = true +inlay-hints.chaining-hints = true completion.autoimport.enable = true completion.postfix.enable = true @@ -31,9 +23,10 @@ files.excludeDirs = [ "src/data/compile_info.rs" ] -macroExpansion.mode = "hir" -macroExpansion.maxDepth = 32 -macroExpansion.engines = { hir = true, tt = true } +macro-expansion.mode = "hir" +macro-expansion.max-depth = 32 +macro-expansion.engines.hir = true +macro-expansion.engines.tt = true workspace.symbol.search.scope = "workspace" diff --git a/systems/_asset/src/asset.rs b/systems/_asset/src/asset.rs index c2b75e6..f452e2b 100644 --- a/systems/_asset/src/asset.rs +++ b/systems/_asset/src/asset.rs @@ -99,21 +99,17 @@ where .open(&lock_path) .await { - Ok(_) => { - return Ok(Handle { - _data_type: PhantomData, - writed: false, - asset_path: self.path.clone(), - lock_path, - temp_path, - }); - } + Ok(_) => Ok(Handle { + _data_type: PhantomData, + writed: false, + asset_path: self.path.clone(), + lock_path, + temp_path, + }), Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => { - return Err(HandleLockError::AssetLocked); - } - Err(e) => { - return Err(HandleLockError::IoError(e)); + Err(HandleLockError::AssetLocked) } + Err(e) => Err(HandleLockError::IoError(e)), } } @@ -231,7 +227,7 @@ where if self.writed { tokio::fs::rename(&from, &to) .await - .map_err(|e| DataApplyError::IoError(e))?; + .map_err(DataApplyError::IoError)?; } Ok(()) } @@ -350,18 +346,15 @@ async fn check_asset_path<D>(handle: &Handle<D>) -> Result<(), PrecheckFailed> where D: RWData<D>, { - if let Some(file_name) = handle.asset_path.file_name() { - if check_path(file_name).is_ok() { - return Ok(()); - } + if let Some(file_name) = handle.asset_path.file_name() + && check_path(file_name).is_ok() + { + return Ok(()); } Err(PrecheckFailed::AssetPathInvalid) } -async fn check_handle_is_cross_directory( - from: &PathBuf, - to: &PathBuf, -) -> Result<(), PrecheckFailed> { +async fn check_handle_is_cross_directory(from: &Path, to: &Path) -> Result<(), PrecheckFailed> { let from_parent = from.parent(); let to_parent = to.parent(); diff --git a/systems/_asset/src/rw.rs b/systems/_asset/src/rw.rs index 9a46144..7595138 100644 --- a/systems/_asset/src/rw.rs +++ b/systems/_asset/src/rw.rs @@ -1,17 +1,17 @@ -use std::path::PathBuf; +use std::path::Path; use crate::error::{DataReadError, DataWriteError}; pub trait RWData<DataType> { /// Implement read logic /// Given a path, return the specific data - fn read(path: &PathBuf) -> impl Future<Output = Result<DataType, DataReadError>> + Send + Sync; + fn read(path: &Path) -> impl Future<Output = Result<DataType, DataReadError>> + Send + Sync; /// Implement write logic /// Given data and a path, write to the filesystem fn write( data: DataType, - path: &PathBuf, + path: &Path, ) -> impl Future<Output = Result<(), DataWriteError>> + Send + Sync; /// Provide test data @@ -42,10 +42,10 @@ pub struct FooData { } impl RWData<FooData> for FooData { - async fn read(path: &PathBuf) -> Result<FooData, DataReadError> { + async fn read(path: &Path) -> Result<FooData, DataReadError> { let content = tokio::fs::read_to_string(path) .await - .map_err(|e| DataReadError::IoError(e))?; + .map_err(DataReadError::IoError)?; let parts: Vec<&str> = content.split('=').collect(); if parts.len() != 2 { return Err(DataReadError::ParseError("Invalid format".to_string())); @@ -57,11 +57,11 @@ impl RWData<FooData> for FooData { Ok(FooData { age, name }) } - async fn write(data: FooData, path: &PathBuf) -> Result<(), DataWriteError> { + async fn write(data: FooData, path: &Path) -> Result<(), DataWriteError> { let content = format!("{}={}", data.name, data.age); tokio::fs::write(path, content) .await - .map_err(|e| DataWriteError::IoError(e))?; + .map_err(DataWriteError::IoError)?; Ok(()) } @@ -75,6 +75,6 @@ impl RWData<FooData> for FooData { fn verify_data(data_a: FooData, data_b: FooData) -> bool { crate::ensure_eq!(data_a.age, data_b.age); crate::ensure_eq!(data_a.name, data_b.name); - return true; + true } } diff --git a/systems/_asset/test/src/lib.rs b/systems/_asset/test/src/lib.rs index 4b62028..d7bf653 100644 --- a/systems/_asset/test/src/lib.rs +++ b/systems/_asset/test/src/lib.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::path::Path; use asset_system::{ RWDataTest, ensure_eq, @@ -13,10 +13,10 @@ pub struct FooData { } impl RWData<FooData> for FooData { - async fn read(path: &PathBuf) -> Result<FooData, DataReadError> { + async fn read(path: &Path) -> Result<FooData, DataReadError> { let content = tokio::fs::read_to_string(path) .await - .map_err(|e| DataReadError::IoError(e))?; + .map_err(DataReadError::IoError)?; let parts: Vec<&str> = content.split('=').collect(); if parts.len() != 2 { return Err(DataReadError::ParseError("Invalid format".to_string())); @@ -28,11 +28,11 @@ impl RWData<FooData> for FooData { Ok(FooData { age, name }) } - async fn write(data: FooData, path: &PathBuf) -> Result<(), DataWriteError> { + async fn write(data: FooData, path: &Path) -> Result<(), DataWriteError> { let content = format!("{}={}", data.name, data.age); tokio::fs::write(path, content) .await - .map_err(|e| DataWriteError::IoError(e))?; + .map_err(DataWriteError::IoError)?; Ok(()) } @@ -46,6 +46,6 @@ impl RWData<FooData> for FooData { fn verify_data(data_a: FooData, data_b: FooData) -> bool { ensure_eq!(data_a.age, data_b.age); ensure_eq!(data_a.name, data_b.name); - return true; + true } } diff --git a/systems/_constants/macros/src/lib.rs b/systems/_constants/macros/src/lib.rs index 7384182..90419c1 100644 --- a/systems/_constants/macros/src/lib.rs +++ b/systems/_constants/macros/src/lib.rs @@ -28,7 +28,7 @@ pub fn constants(attr: TokenStream, item: TokenStream) -> TokenStream { { // Process constant and generate functions if let Some((rust_func, ffi_func)) = - process_constant(&prefix, const_name, const_value) + process_constant(&prefix, const_name, &const_value) { generated_functions.push(rust_func); generated_ffi_functions.push(ffi_func); @@ -51,12 +51,12 @@ pub fn constants(attr: TokenStream, item: TokenStream) -> TokenStream { } fn extract_const_name_and_value(assign: &syn::ExprAssign) -> Option<(Ident, Box<Expr>)> { - if let Expr::Path(path) = &*assign.left { - if let Some(ident) = path.path.get_ident() { - let const_name = ident.clone(); - let const_value = assign.right.clone(); - return Some((const_name, const_value)); - } + if let Expr::Path(path) = &*assign.left + && let Some(ident) = path.path.get_ident() + { + let const_name = ident.clone(); + let const_value = assign.right.clone(); + return Some((const_name, const_value)); } None } @@ -64,12 +64,12 @@ fn extract_const_name_and_value(assign: &syn::ExprAssign) -> Option<(Ident, Box< fn process_constant( prefix: &str, const_name: Ident, - const_value: Box<Expr>, + const_value: &Expr, ) -> Option<(proc_macro2::TokenStream, proc_macro2::TokenStream)> { if let Expr::Lit(ExprLit { lit: Lit::Str(lit_str), .. - }) = *const_value + }) = const_value { let value_str = lit_str.value(); let value_span = lit_str.span(); @@ -209,18 +209,16 @@ fn generate_functions_with_params( let ffi_func = quote! { #[unsafe(no_mangle)] #[allow(nonstandard_style)] - pub extern "C" fn #ffi_fn_ident(#(#ffi_param_decls),*) -> *mut libc::c_char { - unsafe { - #(#ffi_param_checks)* + pub unsafe extern "C" fn #ffi_fn_ident(#(#ffi_param_decls),*) -> *mut libc::c_char { + #(#ffi_param_checks)* - #(#ffi_param_conversions)* + #(#ffi_param_conversions)* - let result = format!(#format_str, #(#ffi_format_args),*); + let result = format!(#format_str, #(#ffi_format_args),*); - match std::ffi::CString::new(result) { - Ok(c) => c.into_raw(), - Err(_) => std::ptr::null_mut(), - } + match std::ffi::CString::new(result) { + Ok(c) => c.into_raw(), + Err(_) => std::ptr::null_mut(), } } }; diff --git a/systems/_framework/src/space.rs b/systems/_framework/src/space.rs index 315bf2b..166120f 100644 --- a/systems/_framework/src/space.rs +++ b/systems/_framework/src/space.rs @@ -52,7 +52,7 @@ impl<T: SpaceRoot> Space<T> { _ => path.to_path_buf(), }; - if !find_space_root_with(&path, &pattern).is_ok() { + if find_space_root_with(&path, pattern).is_err() { T::create_space(&path).await?; } Ok(()) @@ -98,10 +98,10 @@ impl<T: SpaceRoot> Space<T> { /// Otherwise, it is found using the pattern from `T::get_pattern()`. pub fn space_dir(&self, current_dir: impl Into<PathBuf>) -> Result<PathBuf, SpaceError> { // First try to read from cache - if let Ok(lock) = self.space_dir.read() { - if let Some(cached_dir) = lock.as_ref() { - return Ok(cached_dir.clone()); - } + if let Ok(lock) = self.space_dir.read() + && let Some(cached_dir) = lock.as_ref() + { + return Ok(cached_dir.clone()); } // Cache miss, find the space directory @@ -399,7 +399,7 @@ impl<T: SpaceRoot> AsRef<T> for Space<T> { impl<T: SpaceRoot> Deref for Space<T> { type Target = T; fn deref(&self) -> &Self::Target { - &self.as_ref() + self.as_ref() } } @@ -427,7 +427,7 @@ pub enum SpaceRootFindPattern { /// /// For the full implementation, see `find_space_root_with` pub fn find_space_root(pattern: &SpaceRootFindPattern) -> Result<PathBuf, SpaceError> { - find_space_root_with(¤t_dir()?, &pattern) + find_space_root_with(¤t_dir()?, pattern) } /// Find the space directory containing the specified directory, @@ -500,7 +500,7 @@ pub fn find_space_root_with( path.join(dir_name).is_dir() }), SpaceRootFindPattern::IncludeFile(file_name) => { - Box::new(move |path| path.join(&file_name).is_file()) + Box::new(move |path| path.join(file_name).is_file()) } // For absolute paths, return directly diff --git a/systems/sheet/macros/src/lib.rs b/systems/sheet/macros/src/lib.rs index 2990f7e..ea2b139 100644 --- a/systems/sheet/macros/src/lib.rs +++ b/systems/sheet/macros/src/lib.rs @@ -41,8 +41,8 @@ fn parse_id_version(input: &str) -> Result<(bool, u32, u16), String> { let trimmed = input.trim(); // Check if it starts with ~ for local - let (remote, id_part) = if trimmed.starts_with('~') { - (false, &trimmed[1..]) + let (remote, id_part) = if let Some(stripped) = trimmed.strip_prefix('~') { + (false, stripped) } else { (true, trimmed) }; diff --git a/systems/sheet/src/compare.rs b/systems/sheet/src/compare.rs index b5b44b4..95b1aa3 100644 --- a/systems/sheet/src/compare.rs +++ b/systems/sheet/src/compare.rs @@ -7,7 +7,7 @@ use std::cmp::Ordering; /// 4. All other Unicode characters (in their natural order) /// /// The comparison is lexicographic: the first differing element determines the order. -pub fn compare_vec_string(a: &Vec<String>, b: &Vec<String>) -> std::cmp::Ordering { +pub fn compare_vec_string(a: &[String], b: &[String]) -> std::cmp::Ordering { use std::cmp::Ordering; for (left, right) in a.iter().zip(b.iter()) { diff --git a/systems/sheet/src/index_source.rs b/systems/sheet/src/index_source.rs index 43508f2..b11a6b6 100644 --- a/systems/sheet/src/index_source.rs +++ b/systems/sheet/src/index_source.rs @@ -62,7 +62,7 @@ impl IndexSource { impl PartialEq for IndexSource { fn eq(&self, other: &Self) -> bool { - &self.remote == &other.remote && &self.id == &other.id && &self.ver == &other.ver + self.remote == other.remote && self.id == other.id && self.ver == other.ver } } @@ -158,12 +158,6 @@ impl IndexSource { impl std::fmt::Display for IndexSource { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let local_symbol = if self.remote { "" } else { "~" }; - write!( - f, - "{}{}/{}", - local_symbol, - self.id.to_string(), - self.ver.to_string() - ) + write!(f, "{}{}/{}", local_symbol, self.id, self.ver) } } diff --git a/systems/sheet/src/index_source/alias.rs b/systems/sheet/src/index_source/alias.rs index d50c183..8b2cd5b 100644 --- a/systems/sheet/src/index_source/alias.rs +++ b/systems/sheet/src/index_source/alias.rs @@ -139,31 +139,30 @@ async fn get_or_create_alias_file( .read(true) .write(true) .create(true) + .truncate(false) .open(&file_path) .await - .map_err(|e| IDAliasError::Io(e))?; + .map_err(IDAliasError::Io)?; - let metadata = file.metadata().await.map_err(|e| IDAliasError::Io(e))?; + let metadata = file.metadata().await.map_err(IDAliasError::Io)?; if metadata.len() != FILE_SIZE { drop(file); let file = OpenOptions::new() .write(true) .create(true) - .truncate(true) + .truncate(false) .open(&file_path) .await - .map_err(|e| IDAliasError::Io(e))?; + .map_err(IDAliasError::Io)?; - file.set_len(FILE_SIZE) - .await - .map_err(|e| IDAliasError::Io(e))?; + file.set_len(FILE_SIZE).await.map_err(IDAliasError::Io)?; let file = OpenOptions::new() .read(true) .write(true) .open(&file_path) .await - .map_err(|e| IDAliasError::Io(e))?; + .map_err(IDAliasError::Io)?; Ok(file) } else { diff --git a/systems/sheet/src/lazy.rs b/systems/sheet/src/lazy.rs index 2278704..c9ba9df 100644 --- a/systems/sheet/src/lazy.rs +++ b/systems/sheet/src/lazy.rs @@ -8,13 +8,13 @@ macro_rules! lazy_node { #[macro_export] macro_rules! lazy_idx { ($idx:expr, $ver:expr) => { - crate::index_source::IndexSource::new(false, $idx, $ver) + $crate::index_source::IndexSource::new(false, $idx, $ver) }; } #[macro_export] macro_rules! lazy_ridx { ($idx:expr, $ver:expr) => { - crate::index_source::IndexSource::new(true, $idx, $ver) + $crate::index_source::IndexSource::new(true, $idx, $ver) }; } diff --git a/systems/sheet/src/mapping.rs b/systems/sheet/src/mapping.rs index 2e6645e..c1bbafd 100644 --- a/systems/sheet/src/mapping.rs +++ b/systems/sheet/src/mapping.rs @@ -171,7 +171,7 @@ impl LocalMapping { /// Clone and generate a MappingBuf from LocalMapping pub fn to_mapping_buf_cloned(&self, sheet_name: impl Into<String>) -> MappingBuf { - MappingBuf::new(sheet_name.into(), self.val.clone(), self.source.clone()) + MappingBuf::new(sheet_name.into(), self.val.clone(), self.source) } /// Generate a MappingBuf from LocalMapping @@ -235,7 +235,7 @@ impl MappingBuf { /// /// Additionally, if the length of the given forward value exceeds `u8::MAX`, it will also return None pub fn to_local_mapping_cloned(&self, forward: &LocalMappingForward) -> Option<LocalMapping> { - LocalMapping::new(self.val.clone(), self.source.clone(), forward.clone()) + LocalMapping::new(self.val.clone(), self.source, forward.clone()) } /// Generate a LocalMapping from MappingBuf @@ -262,7 +262,7 @@ impl<'a> Mapping<'a> { /// Get the sheet name of Mapping pub fn sheet_name(&self) -> &str { - &self.sheet_name + self.sheet_name } /// Build a Vec of Mapping values from the stored address @@ -276,7 +276,7 @@ impl<'a> Mapping<'a> { /// Get the value str of Mapping pub fn value_str(&self) -> &str { - &self.val + self.val } /// Get the IndexSource of Mapping @@ -301,7 +301,6 @@ impl<'a> Mapping<'a> { fmt_path_str(self.val) .unwrap_or_default() .split('/') - .into_iter() .map(|s| s.to_string()) .collect(), self.source, @@ -320,7 +319,6 @@ impl<'a> Mapping<'a> { fmt_path_str(self.val) .unwrap_or_default() .split("/") - .into_iter() .map(|s| s.to_string()) .collect(), self.source, @@ -404,36 +402,26 @@ impl std::fmt::Display for LocalMapping { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match &self.forward { LocalMappingForward::Latest => { - write!( - f, - "\"{}\" => \"{}\"", - self.val.join("/"), - self.source.to_string() - ) + write!(f, "\"{}\" => \"{}\"", self.val.join("/"), self.source) } LocalMappingForward::Ref { sheet_name } => { write!( f, "\"{}\" => \"{}\" => \"{}\"", self.val.join("/"), - self.source.to_string(), + self.source, sheet_name ) } LocalMappingForward::Version { version } => { if &self.mapped_version() == version { - write!( - f, - "\"{}\" == \"{}\"", - self.val.join("/"), - self.source.to_string(), - ) + write!(f, "\"{}\" == \"{}\"", self.val.join("/"), self.source,) } else { write!( f, "\"{}\" => \"{}\" == \"{}\"", self.val.join("/"), - self.source.to_string(), + self.source, version ) } @@ -556,7 +544,7 @@ fn join_helper(nodes: String, mut mapping_buf_val: Vec<String>) -> Vec<String> { } } - return mapping_buf_val; + mapping_buf_val } // Implement mutual comparison for MappingBuf and Mapping @@ -637,7 +625,7 @@ impl std::borrow::Borrow<Vec<String>> for MappingBuf { /// ``` pub fn node(str: impl Into<String>) -> Vec<String> { let str = just_fmt::fmt_path::fmt_path_str(str).unwrap_or_default(); - str.split("/").into_iter().map(|f| f.to_string()).collect() + str.split("/").map(|f| f.to_string()).collect() } // Implement comparison for LocalMapping diff --git a/systems/sheet/src/mapping/parse.rs b/systems/sheet/src/mapping/parse.rs index e203c96..7460ffd 100644 --- a/systems/sheet/src/mapping/parse.rs +++ b/systems/sheet/src/mapping/parse.rs @@ -178,9 +178,7 @@ impl TryFrom<&str> for LocalMapping { Ok(LocalMapping { val, source, - forward: LocalMappingForward::Ref { - sheet_name: sheet_name, - }, + forward: LocalMappingForward::Ref { sheet_name }, }) } _ => Err(ParseMappingError::InvalidMapping), diff --git a/systems/sheet/src/sheet.rs b/systems/sheet/src/sheet.rs index fdcdd67..96fca9a 100644 --- a/systems/sheet/src/sheet.rs +++ b/systems/sheet/src/sheet.rs @@ -1,7 +1,6 @@ use std::{ collections::HashSet, fs::File, - mem::replace, path::{Path, PathBuf}, }; @@ -139,14 +138,14 @@ impl std::fmt::Display for SheetEditItem { write!(f, "erase \"{}\"", display_node_helper(node),) } SheetEditItem::InsertMapping { mapping } => { - write!(f, "Insert {}", mapping.to_string()) + write!(f, "Insert {}", mapping) } SheetEditItem::ReplaceSource { node, source } => { write!( f, "Replace \"{}\" => \"{}\"", display_node_helper(node), - source.to_string() + source ) } SheetEditItem::UpdateForward { node, forward } => match forward { @@ -177,7 +176,7 @@ impl std::fmt::Display for SheetEditItem { } #[inline(always)] -fn display_node_helper(n: &Vec<String>) -> String { +fn display_node_helper(n: &[String]) -> String { n.join("/") } @@ -201,7 +200,7 @@ impl SheetData { } /// Load MMAP from a Sheet file - pub fn mmap<'a>(sheet_file: impl AsRef<Path>) -> std::io::Result<SheetDataMmap> { + pub fn mmap(sheet_file: impl AsRef<Path>) -> std::io::Result<SheetDataMmap> { let file = File::open(sheet_file.as_ref())?; // SAFETY: The file has been successfully opened and is managed by the SheetDataMmap wrapper @@ -244,7 +243,7 @@ impl SheetDataMmap { } /// Load mapping information from Sheet file at high speed and copy into LocalMapping - pub fn mp_c<'a>(&self, node: &[&str]) -> Result<Option<LocalMapping>, ReadSheetDataError> { + pub fn mp_c(&self, node: &[&str]) -> Result<Option<LocalMapping>, ReadSheetDataError> { match self.mp(node)? { Some((mapping, forward)) => { // Note: @@ -291,10 +290,8 @@ impl Sheet { /// Read from Sheet data and clone into MappingBuf pub fn read_mapping_buf(&self, value: &Vec<String>) -> Option<MappingBuf> { - match self.read_local_mapping(value) { - Some(v) => Some(v.to_mapping_buf_cloned(&self.name)), - None => None, - } + self.read_local_mapping(value) + .map(|v| v.to_mapping_buf_cloned(&self.name)) } /// Insert mapping move @@ -410,7 +407,7 @@ impl Sheet { /// Apply changes pub fn apply(&mut self) -> Result<(), SheetApplyError> { - let items = replace(&mut self.edit.list, Vec::new()); + let items = std::mem::take(&mut self.edit.list); for item in items { match item { SheetEditItem::DoNothing => continue, @@ -516,9 +513,9 @@ impl TryFrom<&str> for SheetData { continue; } let mapping = LocalMapping::try_from(line)?; - let _ = sheet.insert_mapping(mapping)?; + sheet.insert_mapping(mapping)?; } - let _ = sheet.apply()?; + sheet.apply()?; Ok(sheet.unpack()) } } @@ -552,7 +549,7 @@ impl TryFrom<&[u8]> for SheetData { } impl RWData<SheetData> for SheetData { - async fn read(path: &PathBuf) -> Result<SheetData, asset_system::error::DataReadError> { + async fn read(path: &Path) -> Result<SheetData, asset_system::error::DataReadError> { let mut data = SheetData::empty(); data.full_read(path).await.map_err(|e| match e { ReadSheetDataError::IOErr(error) => DataReadError::IoError(error), @@ -562,11 +559,11 @@ impl RWData<SheetData> for SheetData { async fn write( data: SheetData, - path: &PathBuf, + path: &Path, ) -> Result<(), asset_system::error::DataWriteError> { tokio::fs::write(path, data.as_bytes()) .await - .map_err(|e| asset_system::error::DataWriteError::IoError(e.into())) + .map_err(asset_system::error::DataWriteError::IoError) } fn test_data() -> SheetData { diff --git a/systems/sheet/src/sheet/v1/constants.rs b/systems/sheet/src/sheet/v1/constants.rs index 7073278..eec7b5c 100644 --- a/systems/sheet/src/sheet/v1/constants.rs +++ b/systems/sheet/src/sheet/v1/constants.rs @@ -7,8 +7,7 @@ // [OFFSET_INDEX_TABLE: u32] pub const CURRENT_SHEET_VERSION: u8 = 1; -pub const HEADER_SIZE: usize = 0 - + 1 // SHEET_VERSION +pub const HEADER_SIZE: usize = 1 // SHEET_VERSION + 2 // MAPPING_BUCKET_COUNT + 4 // INDEX_COUNT + 4 // OFFSET_MAPPING_DIR @@ -21,8 +20,7 @@ pub const HEADER_SIZE: usize = 0 // [BUCKET_OFFSET: u32] // [BUCKET_LENGTH: u32] -pub const MAPPING_DIR_ENTRY_SIZE: usize = 0 - + 4 // BUCKET_HASH_PREFIX +pub const MAPPING_DIR_ENTRY_SIZE: usize = 4 // BUCKET_HASH_PREFIX + 4 // BUCKET_OFFSET + 4 // BUCKET_LENGTH ; @@ -36,8 +34,7 @@ pub const MAPPING_DIR_ENTRY_SIZE: usize = 0 // [FORWARD_INFO_BYTES: ?] // [INDEX_OFFSET: u32] -pub const MAPPING_BUCKET_MIN_SIZE: usize = 0 - + 1 // KEY_LEN +pub const MAPPING_BUCKET_MIN_SIZE: usize = 1 // KEY_LEN + 1 // FORWARD_TYPE + 1 // FORWARD_INFO_LEN + 2 // KEY_BYTES (MIN:1) + FORWARD_INFO_BYTES (MIN:1) @@ -51,8 +48,7 @@ pub const MAPPING_BUCKET_MIN_SIZE: usize = 0 // [REMOTE_FLAG: u8] // [RESERVED: u8; 3] -pub const INDEX_ENTRY_SIZE: usize = 0 - + 4 // INDEX_ID +pub const INDEX_ENTRY_SIZE: usize = 4 // INDEX_ID + 2 // INDEX_VERSION + 1 // REMOTE_FLAG + 3 // RESERVED diff --git a/systems/sheet/src/sheet/v1/writer.rs b/systems/sheet/src/sheet/v1/writer.rs index 4c580b2..fdc4caa 100644 --- a/systems/sheet/src/sheet/v1/writer.rs +++ b/systems/sheet/src/sheet/v1/writer.rs @@ -18,9 +18,9 @@ pub fn convert_sheet_data_to_bytes(sheet_data: SheetData) -> Vec<u8> { for mapping in &mappings { let source = mapping.index_source(); let key = (source.is_remote(), source.id(), source.version()); - if !source_to_offset.contains_key(&key) { + if let std::collections::hash_map::Entry::Vacant(e) = source_to_offset.entry(key) { let offset = index_sources.len() as u32; - source_to_offset.insert(key, offset); + e.insert(offset); index_sources.push(IndexSource::new( source.is_remote(), source.id(), @@ -36,10 +36,7 @@ pub fn convert_sheet_data_to_bytes(sheet_data: SheetData) -> Vec<u8> { for mapping in mappings { let hash = calculate_path_hash(mapping.value()); let bucket_key = hash >> 16; // Take high 16 bits as bucket key - buckets - .entry(bucket_key) - .or_insert_with(Vec::new) - .push(mapping); + buckets.entry(bucket_key).or_default().push(mapping); } let bucket_count = buckets.len() as u16; diff --git a/systems/vault/src/vault/config.rs b/systems/vault/src/vault/config.rs index 329f78e..c552e15 100644 --- a/systems/vault/src/vault/config.rs +++ b/systems/vault/src/vault/config.rs @@ -1,3 +1,5 @@ +use std::path::Path; + use asset_system::{RWDataTest, rw::RWData}; use config_system::rw::{read_config, write_config}; use serde::{Deserialize, Serialize}; @@ -6,30 +8,26 @@ use serde::{Deserialize, Serialize}; pub struct VaultConfig {} impl RWData<VaultConfig> for VaultConfig { - async fn read( - path: &std::path::PathBuf, - ) -> Result<VaultConfig, asset_system::error::DataReadError> { + async fn read(path: &Path) -> Result<VaultConfig, asset_system::error::DataReadError> { let read_config = read_config(path).await; match read_config { Ok(config) => Ok(config), Err(e) => Err(asset_system::error::DataReadError::IoError( - std::io::Error::new(std::io::ErrorKind::Other, e), + std::io::Error::other(e), )), } } async fn write( data: VaultConfig, - path: &std::path::PathBuf, + path: &Path, ) -> Result<(), asset_system::error::DataWriteError> { let write_config = write_config(path, &data).await; match write_config { Ok(_) => Ok(()), - Err(e) => { - return Err(asset_system::error::DataWriteError::IoError( - std::io::Error::new(std::io::ErrorKind::Other, e), - )); - } + Err(e) => Err(asset_system::error::DataWriteError::IoError( + std::io::Error::other(e), + )), } } @@ -38,6 +36,6 @@ impl RWData<VaultConfig> for VaultConfig { } fn verify_data(data_a: VaultConfig, data_b: VaultConfig) -> bool { - &data_a == &data_b + data_a == data_b } } diff --git a/systems/vault/src/vault/manager.rs b/systems/vault/src/vault/manager.rs index bae26d4..249d020 100644 --- a/systems/vault/src/vault/manager.rs +++ b/systems/vault/src/vault/manager.rs @@ -8,6 +8,12 @@ pub struct VaultManager { space: Space<Vault>, } +impl Default for VaultManager { + fn default() -> Self { + Self::new() + } +} + impl VaultManager { pub fn new() -> Self { VaultManager { diff --git a/systems/workspace/src/workspace/config.rs b/systems/workspace/src/workspace/config.rs index f43dc0e..a494db3 100644 --- a/systems/workspace/src/workspace/config.rs +++ b/systems/workspace/src/workspace/config.rs @@ -1,4 +1,4 @@ -use std::{io::Error, path::PathBuf}; +use std::{io::Error, path::Path}; use asset_system::{ RWDataTest, @@ -85,27 +85,19 @@ impl WorkspaceConfig { } impl RWData<WorkspaceConfig> for WorkspaceConfig { - async fn read(path: &PathBuf) -> Result<WorkspaceConfig, DataReadError> { + async fn read(path: &Path) -> Result<WorkspaceConfig, DataReadError> { let read_config = read_config(path).await; match read_config { Ok(config) => Ok(config), - Err(e) => Err(DataReadError::IoError(Error::new( - std::io::ErrorKind::Other, - e, - ))), + Err(e) => Err(DataReadError::IoError(Error::other(e))), } } - async fn write(data: WorkspaceConfig, path: &PathBuf) -> Result<(), DataWriteError> { + async fn write(data: WorkspaceConfig, path: &Path) -> Result<(), DataWriteError> { let write_config = write_config(path, &data).await; match write_config { Ok(_) => Ok(()), - Err(e) => { - return Err(DataWriteError::IoError(Error::new( - std::io::ErrorKind::Other, - e, - ))); - } + Err(e) => Err(DataWriteError::IoError(Error::other(e))), } } @@ -114,6 +106,6 @@ impl RWData<WorkspaceConfig> for WorkspaceConfig { } fn verify_data(data_a: WorkspaceConfig, data_b: WorkspaceConfig) -> bool { - &data_a == &data_b + data_a == data_b } } diff --git a/systems/workspace/src/workspace/manager.rs b/systems/workspace/src/workspace/manager.rs index fef36ab..7e8fc47 100644 --- a/systems/workspace/src/workspace/manager.rs +++ b/systems/workspace/src/workspace/manager.rs @@ -10,6 +10,12 @@ pub struct WorkspaceManager { pub(crate) space: Space<Workspace>, } +impl Default for WorkspaceManager { + fn default() -> Self { + Self::new() + } +} + impl WorkspaceManager { pub fn new() -> Self { WorkspaceManager { diff --git a/systems/workspace/src/workspace/manager/id_aliases.rs b/systems/workspace/src/workspace/manager/id_aliases.rs index a5a509c..4ce659d 100644 --- a/systems/workspace/src/workspace/manager/id_aliases.rs +++ b/systems/workspace/src/workspace/manager/id_aliases.rs @@ -51,7 +51,7 @@ impl WorkspaceManager { let aliases_dir = self.get_space().local_path(workspace_dir_id_mapping())?; IndexSourceAliasesManager::write_alias(aliases_dir, local_id, remote_id) .await - .map_err(|e| WorkspaceOperationError::IDAliasError(e)) + .map_err(WorkspaceOperationError::IDAliasError) } /// Delete a alias between local and remote IDs @@ -59,7 +59,7 @@ impl WorkspaceManager { let aliases_dir = self.get_space().local_path(workspace_dir_id_mapping())?; IndexSourceAliasesManager::delete_alias(aliases_dir, local_id) .await - .map_err(|e| WorkspaceOperationError::IDAliasError(e)) + .map_err(WorkspaceOperationError::IDAliasError) } /// Check if a alias exists between local and remote IDs @@ -67,6 +67,6 @@ impl WorkspaceManager { let aliases_dir = self.get_space().local_path(workspace_dir_id_mapping())?; IndexSourceAliasesManager::alias_exists(aliases_dir, local_id) .await - .map_err(|e| WorkspaceOperationError::IDAliasError(e)) + .map_err(WorkspaceOperationError::IDAliasError) } } diff --git a/systems/workspace/src/workspace/manager/sheet_state.rs b/systems/workspace/src/workspace/manager/sheet_state.rs index b7cd4fd..eddfa84 100644 --- a/systems/workspace/src/workspace/manager/sheet_state.rs +++ b/systems/workspace/src/workspace/manager/sheet_state.rs @@ -47,7 +47,7 @@ impl WorkspaceManager { if sheet_path.exists() { // If reading fails, treat it as if the sheet does not exist and return `None` sheet_data.full_read(sheet_path).await.ok()?; - return Some(sheet_data.pack(sheet_name)); + Some(sheet_data.pack(sheet_name)) } else { None } @@ -72,7 +72,7 @@ impl WorkspaceManager { pub fn get_sheet_path(&self, sheet_name: impl AsRef<str>) -> PathBuf { let sheet_name = sheet_name.as_ref(); self.space - .local_path(workspace_file_sheet(&sheet_name)) + .local_path(workspace_file_sheet(sheet_name)) // The `local_path` only produces path formatting errors. // If the path cannot be guaranteed to be correct, // execution should not continue, so we unwrap() @@ -85,12 +85,11 @@ impl WorkspaceManager { if let Ok(mut read_dir) = self.space.read_dir(workspace_dir_local_sheets()).await { while let Some(entry) = read_dir.next_entry().await.ok().flatten() { let path = entry.path(); - if path.is_file() { - if let Some(file_name) = path.file_stem() { - if let Some(name_str) = file_name.to_str() { - sheet_names.push(name_str.to_string()); - } - } + if path.is_file() + && let Some(file_name) = path.file_stem() + && let Some(name_str) = file_name.to_str() + { + sheet_names.push(name_str.to_string()); } } } diff --git a/utils/hex_display/src/lib.rs b/utils/hex_display/src/lib.rs index 833ab22..a861bee 100644 --- a/utils/hex_display/src/lib.rs +++ b/utils/hex_display/src/lib.rs @@ -76,7 +76,7 @@ fn write_ascii(result: &mut String, chunk: &[u8]) { result.push_str(" |"); for &byte in chunk { - if byte >= 32 && byte <= 126 { + if (32..=126).contains(&byte) { result.push(byte as char); } else { result.push('.'); diff --git a/utils/tcp_connection/src/instance_challenge.rs b/utils/tcp_connection/src/instance_challenge.rs index 12fce54..bb1fcf0 100644 --- a/utils/tcp_connection/src/instance_challenge.rs +++ b/utils/tcp_connection/src/instance_challenge.rs @@ -106,7 +106,7 @@ impl ConnectionInstance { rand::TryRng::try_fill_bytes(&mut rng, &mut challenge).map_err(|e| { TcpTargetError::Crypto(format!("Failed to generate random challenge: {}", e)) })?; - return Ok(challenge); + Ok(challenge) } /// Accepts a challenge from the target machine to verify connection security |
