diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-01-16 17:15:52 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-01-16 17:33:09 +0200 |
commit | 6ed7241df0accea0d06beefa6aa39543b3a138e3 (patch) | |
tree | 1ddb56e4a431421043bd72d38a895f2bd73f23ea | |
parent | 61ea591bd254a240bb8c45221dea057c1517b0ae (diff) | |
download | obnam2-6ed7241df0accea0d06beefa6aa39543b3a138e3.tar.gz |
refactor: rename AsyncBackupClient to just BackupClient
There is only async.
Sponsored-by: author
-rw-r--r-- | src/backup_run.rs | 11 | ||||
-rw-r--r-- | src/client.rs | 14 | ||||
-rw-r--r-- | src/cmd/backup.rs | 4 | ||||
-rw-r--r-- | src/cmd/gen_info.rs | 4 | ||||
-rw-r--r-- | src/cmd/get_chunk.rs | 4 | ||||
-rw-r--r-- | src/cmd/list.rs | 4 | ||||
-rw-r--r-- | src/cmd/list_files.rs | 4 | ||||
-rw-r--r-- | src/cmd/resolve.rs | 4 | ||||
-rw-r--r-- | src/cmd/restore.rs | 8 | ||||
-rw-r--r-- | src/cmd/show_gen.rs | 4 |
10 files changed, 28 insertions, 33 deletions
diff --git a/src/backup_run.rs b/src/backup_run.rs index ade5ee0..2286fca 100644 --- a/src/backup_run.rs +++ b/src/backup_run.rs @@ -5,7 +5,7 @@ use crate::backup_reason::Reason; use crate::chunk::{GenerationChunk, GenerationChunkError}; use crate::chunker::{Chunker, ChunkerError}; use crate::chunkid::ChunkId; -use crate::client::{AsyncBackupClient, ClientError}; +use crate::client::{BackupClient, ClientError}; use crate::config::ClientConfig; use crate::error::ObnamError; use crate::fsentry::{FilesystemEntry, FilesystemKind}; @@ -24,7 +24,7 @@ const SQLITE_CHUNK_SIZE: usize = MIB as usize; /// A running backup. pub struct BackupRun<'a> { - client: &'a AsyncBackupClient, + client: &'a BackupClient, policy: BackupPolicy, buffer_size: usize, progress: Option<BackupProgress>, @@ -95,10 +95,7 @@ pub struct RootsBackupOutcome { impl<'a> BackupRun<'a> { /// Create a new run for an initial backup. - pub fn initial( - config: &ClientConfig, - client: &'a AsyncBackupClient, - ) -> Result<Self, BackupError> { + pub fn initial(config: &ClientConfig, client: &'a BackupClient) -> Result<Self, BackupError> { Ok(Self { client, policy: BackupPolicy::default(), @@ -110,7 +107,7 @@ impl<'a> BackupRun<'a> { /// Create a new run for an incremental backup. pub fn incremental( config: &ClientConfig, - client: &'a AsyncBackupClient, + client: &'a BackupClient, ) -> Result<Self, BackupError> { Ok(Self { client, diff --git a/src/client.rs b/src/client.rs index ed6b86b..e9b00cd 100644 --- a/src/client.rs +++ b/src/client.rs @@ -96,18 +96,16 @@ pub enum ClientError { } /// Client for the Obnam server HTTP API. -/// -/// This is the async version. -pub struct AsyncBackupClient { - chunk_client: AsyncChunkClient, +pub struct BackupClient { + chunk_client: ChunkClient, } -impl AsyncBackupClient { +impl BackupClient { /// Create a new backup client. pub fn new(config: &ClientConfig) -> Result<Self, ClientError> { info!("creating backup client with config: {:#?}", config); Ok(Self { - chunk_client: AsyncChunkClient::new(config)?, + chunk_client: ChunkClient::new(config)?, }) } @@ -162,13 +160,13 @@ impl AsyncBackupClient { } /// Client for using chunk part of Obnam server HTTP API. -pub struct AsyncChunkClient { +pub struct ChunkClient { client: reqwest::Client, base_url: String, cipher: CipherEngine, } -impl AsyncChunkClient { +impl ChunkClient { /// Create a new chunk client. pub fn new(config: &ClientConfig) -> Result<Self, ClientError> { let pass = config.passwords()?; diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs index 6e09d37..92b0f40 100644 --- a/src/cmd/backup.rs +++ b/src/cmd/backup.rs @@ -1,7 +1,7 @@ //! The `backup` subcommand. use crate::backup_run::BackupRun; -use crate::client::AsyncBackupClient; +use crate::client::BackupClient; use crate::config::ClientConfig; use crate::error::ObnamError; use crate::generation::GenId; @@ -26,7 +26,7 @@ impl Backup { async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> { let runtime = SystemTime::now(); - let client = AsyncBackupClient::new(config)?; + let client = BackupClient::new(config)?; let genlist = client.list_generations().await?; let oldtemp = NamedTempFile::new()?; diff --git a/src/cmd/gen_info.rs b/src/cmd/gen_info.rs index 2663d9b..2ce1f64 100644 --- a/src/cmd/gen_info.rs +++ b/src/cmd/gen_info.rs @@ -1,6 +1,6 @@ //! The `gen-info` subcommand. -use crate::client::AsyncBackupClient; +use crate::client::BackupClient; use crate::config::ClientConfig; use crate::error::ObnamError; use log::info; @@ -26,7 +26,7 @@ impl GenInfo { async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> { let temp = NamedTempFile::new()?; - let client = AsyncBackupClient::new(config)?; + let client = BackupClient::new(config)?; let genlist = client.list_generations().await?; let gen_id = genlist.resolve(&self.gen_ref)?; diff --git a/src/cmd/get_chunk.rs b/src/cmd/get_chunk.rs index 905e997..0b27084 100644 --- a/src/cmd/get_chunk.rs +++ b/src/cmd/get_chunk.rs @@ -1,7 +1,7 @@ //! The `get-chunk` subcommand. use crate::chunkid::ChunkId; -use crate::client::AsyncBackupClient; +use crate::client::BackupClient; use crate::config::ClientConfig; use crate::error::ObnamError; use std::io::{stdout, Write}; @@ -24,7 +24,7 @@ impl GetChunk { } async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> { - let client = AsyncBackupClient::new(config)?; + let client = BackupClient::new(config)?; let chunk_id: ChunkId = self.chunk_id.parse().unwrap(); let chunk = client.fetch_chunk(&chunk_id).await?; let stdout = stdout(); diff --git a/src/cmd/list.rs b/src/cmd/list.rs index 6c58e30..f176594 100644 --- a/src/cmd/list.rs +++ b/src/cmd/list.rs @@ -1,6 +1,6 @@ //! The `list` subcommand. -use crate::client::AsyncBackupClient; +use crate::client::BackupClient; use crate::config::ClientConfig; use crate::error::ObnamError; use structopt::StructOpt; @@ -18,7 +18,7 @@ impl List { } async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> { - let client = AsyncBackupClient::new(config)?; + let client = BackupClient::new(config)?; let generations = client.list_generations().await?; for finished in generations.iter() { diff --git a/src/cmd/list_files.rs b/src/cmd/list_files.rs index 888943e..12d34b1 100644 --- a/src/cmd/list_files.rs +++ b/src/cmd/list_files.rs @@ -1,7 +1,7 @@ //! The `list-files` subcommand. use crate::backup_reason::Reason; -use crate::client::AsyncBackupClient; +use crate::client::BackupClient; use crate::config::ClientConfig; use crate::error::ObnamError; use crate::fsentry::{FilesystemEntry, FilesystemKind}; @@ -27,7 +27,7 @@ impl ListFiles { async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> { let temp = NamedTempFile::new()?; - let client = AsyncBackupClient::new(config)?; + let client = BackupClient::new(config)?; let genlist = client.list_generations().await?; let gen_id = genlist.resolve(&self.gen_id)?; diff --git a/src/cmd/resolve.rs b/src/cmd/resolve.rs index cd08908..3b9570a 100644 --- a/src/cmd/resolve.rs +++ b/src/cmd/resolve.rs @@ -1,6 +1,6 @@ //! The `resolve` subcommand. -use crate::client::AsyncBackupClient; +use crate::client::BackupClient; use crate::config::ClientConfig; use crate::error::ObnamError; use structopt::StructOpt; @@ -21,7 +21,7 @@ impl Resolve { } async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> { - let client = AsyncBackupClient::new(config)?; + let client = BackupClient::new(config)?; let generations = client.list_generations().await?; match generations.resolve(&self.generation) { diff --git a/src/cmd/restore.rs b/src/cmd/restore.rs index 2a36986..7b3d95e 100644 --- a/src/cmd/restore.rs +++ b/src/cmd/restore.rs @@ -1,7 +1,7 @@ //! The `restore` subcommand. use crate::backup_reason::Reason; -use crate::client::{AsyncBackupClient, ClientError}; +use crate::client::{BackupClient, ClientError}; use crate::config::ClientConfig; use crate::error::ObnamError; use crate::fsentry::{FilesystemEntry, FilesystemKind}; @@ -43,7 +43,7 @@ impl Restore { async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> { let temp = NamedTempFile::new()?; - let client = AsyncBackupClient::new(config)?; + let client = BackupClient::new(config)?; let genlist = client.list_generations().await?; let gen_id = genlist.resolve(&self.gen_id)?; @@ -130,7 +130,7 @@ pub enum RestoreError { } async fn restore_generation( - client: &AsyncBackupClient, + client: &BackupClient, gen: &LocalGeneration, fileid: i64, entry: &FilesystemEntry, @@ -182,7 +182,7 @@ fn restored_path(entry: &FilesystemEntry, to: &Path) -> Result<PathBuf, RestoreE } async fn restore_regular( - client: &AsyncBackupClient, + client: &BackupClient, gen: &LocalGeneration, path: &Path, fileid: i64, diff --git a/src/cmd/show_gen.rs b/src/cmd/show_gen.rs index 6ec1203..6c8ba19 100644 --- a/src/cmd/show_gen.rs +++ b/src/cmd/show_gen.rs @@ -1,6 +1,6 @@ //! The `show-generation` subcommand. -use crate::client::AsyncBackupClient; +use crate::client::BackupClient; use crate::config::ClientConfig; use crate::error::ObnamError; use crate::fsentry::FilesystemKind; @@ -26,7 +26,7 @@ impl ShowGeneration { async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> { let temp = NamedTempFile::new()?; - let client = AsyncBackupClient::new(config)?; + let client = BackupClient::new(config)?; let genlist = client.list_generations().await?; let gen_id = genlist.resolve(&self.gen_id)?; |