diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-20 21:54:29 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-20 21:57:49 +0800 |
| commit | 9a60751a901f568bdeb154c4115235d4f3a0f8b9 (patch) | |
| tree | 65df323f6478bae51473a3d6471df39a596ce9c5 /systems/vault | |
| parent | a9e5c086584d3e697188be7003f564e7e2137135 (diff) | |
Apply clippy suggestions and improve code quality
Diffstat (limited to 'systems/vault')
| -rw-r--r-- | systems/vault/src/vault/config.rs | 20 | ||||
| -rw-r--r-- | systems/vault/src/vault/manager.rs | 6 |
2 files changed, 15 insertions, 11 deletions
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 { |
