diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-01-05 15:48:16 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-01-05 15:48:16 +0100 |
| commit | b17907faf8d9693cef94a6048d802bd4ced9102f (patch) | |
| tree | 1bd87c40e85af675a96b63672163b4caaa174364 /src/remote/mod.rs | |
| parent | d7fef30ac3f539975ef9edbba8e0af4a4e9ff3de (diff) | |
Deal with all lints
Diffstat (limited to 'src/remote/mod.rs')
| -rw-r--r-- | src/remote/mod.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/remote/mod.rs b/src/remote/mod.rs index 49bfeb0..6561936 100644 --- a/src/remote/mod.rs +++ b/src/remote/mod.rs @@ -2,30 +2,30 @@ mod git; use std::fs::{create_dir_all, remove_file, write, File}; use std::io::{Error, ErrorKind::Other, Read, Result}; -use std::path::PathBuf; +use std::path::Path; use git::Git; pub trait Remote { fn can_handle(&self, remote: &str) -> bool; - fn sync_up(&self, remote: &str, directory: &PathBuf) -> Result<()>; - fn sync_down(&self, remote: &str, directory: &PathBuf) -> Result<()>; + fn sync_up(&self, remote: &str, directory: &Path) -> Result<()>; + fn sync_down(&self, remote: &str, directory: &Path) -> Result<()>; } -pub fn add(config_directory: &PathBuf, remote_config: &PathBuf, remote: &String) -> Result<()> { +pub fn add(config_directory: &Path, remote_config: &Path, remote: &String) -> Result<()> { create_dir_all(config_directory)?; write(remote_config, remote)?; Ok(()) } -pub fn remove(remote_config: &PathBuf) -> Result<()> { +pub fn remove(remote_config: &Path) -> Result<()> { if remote_config.exists() { - remove_file(remote_config)? + remove_file(remote_config)?; } Ok(()) } -pub fn sync_up(data_directory: &PathBuf, remote_config: &PathBuf) -> Result<()> { +pub fn sync_up(data_directory: &Path, remote_config: &Path) -> Result<()> { let remote_address = read_remote(remote_config).ok_or_else(|| Error::new(Other, "No remote is configured"))?; create_dir_all(data_directory)?; @@ -41,7 +41,7 @@ pub fn sync_up(data_directory: &PathBuf, remote_config: &PathBuf) -> Result<()> )) } -pub fn sync_down(data_directory: &PathBuf, remote_config: &PathBuf) -> Result<()> { +pub fn sync_down(data_directory: &Path, remote_config: &Path) -> Result<()> { let remote_address = read_remote(remote_config).ok_or_else(|| Error::new(Other, "No remote is configured"))?; create_dir_all(data_directory)?; @@ -61,7 +61,7 @@ fn available_remotes() -> Vec<Box<dyn Remote>> { vec![Box::new(Git::new())] } -fn read_remote(file_path: &PathBuf) -> Option<String> { +fn read_remote(file_path: &Path) -> Option<String> { let mut file = File::open(file_path).ok()?; let mut contents = String::new(); file.read_to_string(&mut contents).ok()?; |