[pbs-devel] [PATCH proxmox-backup 1/2] change * imports of proxmox_backup::client
Mira Limbeck
m.limbeck at proxmox.com
Fri Jul 17 17:43:47 CEST 2020
Change the src/client.rs to make the modules public instead of
publically using each member. This simplified the code and keeps the
behaviour almost the same. Instead of using
'use proxmox_backup::client::*' we now have to use the full path
(e.g. 'use proxmox_backup::client::http_client::<Symbol>') instead.
This makes it clear where each symbol can be found.
As the client module is used in some other files, we need to adapt them
as well.
Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
It would be possible to keep the 'pub use <module>::*' lines so a
proxmox_backup::client::* import still works.
In my opinion this makes it a lot easier to look up symbols as you know
where they can be found instead of having to grep for the definitions.
What is your opinion on this matter?
Note: The use statements were formatted with rustfmt.
src/api2/pull.rs | 6 +++++-
src/bin/proxmox-backup-client.rs | 14 +++++++++++--
src/bin/proxmox-backup-manager.rs | 5 ++++-
src/bin/proxmox-backup-proxy.rs | 6 +++++-
src/bin/proxmox_backup_client/benchmark.rs | 2 +-
src/bin/proxmox_backup_client/catalog.rs | 2 +-
src/bin/proxmox_backup_client/mount.rs | 2 +-
src/bin/proxmox_backup_client/task.rs | 2 +-
src/client.rs | 24 ++++++++--------------
src/client/backup_reader.rs | 2 +-
src/client/backup_writer.rs | 2 +-
src/client/pull.rs | 5 ++++-
src/client/remote_chunk_reader.rs | 2 +-
src/client/task_log.rs | 2 +-
14 files changed, 46 insertions(+), 30 deletions(-)
diff --git a/src/api2/pull.rs b/src/api2/pull.rs
index cf7de524..d8991919 100644
--- a/src/api2/pull.rs
+++ b/src/api2/pull.rs
@@ -8,7 +8,11 @@ use proxmox::api::{ApiMethod, Router, RpcEnvironment, Permission};
use crate::server::{WorkerTask};
use crate::backup::DataStore;
-use crate::client::{HttpClient, HttpClientOptions, BackupRepository, pull::pull_store};
+use crate::client::{
+ backup_repo::BackupRepository,
+ http_client::{HttpClient, HttpClientOptions},
+ pull::pull_store
+};
use crate::api2::types::*;
use crate::config::{
remote,
diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs
index d0620c0d..147eeba6 100644
--- a/src/bin/proxmox-backup-client.rs
+++ b/src/bin/proxmox-backup-client.rs
@@ -26,7 +26,17 @@ use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation};
use proxmox_backup::tools;
use proxmox_backup::api2::types::*;
use proxmox_backup::api2::version;
-use proxmox_backup::client::*;
+use proxmox_backup::client::{
+ backup_reader::BackupReader,
+ backup_repo::{BackupRepository, BACKUP_REPO_URL},
+ backup_specification::{
+ parse_backup_specification, BackupSpecificationType, BACKUP_SOURCE_SCHEMA,
+ },
+ backup_writer::{BackupStats, BackupWriter},
+ http_client::{delete_ticket_info, HttpClient, HttpClientOptions},
+ pxar_backup_stream::PxarBackupStream,
+ task_log::display_task_log,
+};
use proxmox_backup::pxar::catalog::*;
use proxmox_backup::backup::{
archive_type,
@@ -1826,7 +1836,7 @@ fn complete_chunk_size(_arg: &str, _param: &HashMap<String, String>) -> Vec<Stri
result
}
-use proxmox_backup::client::RemoteChunkReader;
+use proxmox_backup::client::remote_chunk_reader::RemoteChunkReader;
/// This is a workaround until we have cleaned up the chunk/reader/... infrastructure for better
/// async use!
///
diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs
index 7ae0852f..4ef8d340 100644
--- a/src/bin/proxmox-backup-manager.rs
+++ b/src/bin/proxmox-backup-manager.rs
@@ -8,7 +8,10 @@ use proxmox::api::{api, cli::*, RpcEnvironment};
use proxmox_backup::tools;
use proxmox_backup::config;
use proxmox_backup::api2::{self, types::* };
-use proxmox_backup::client::*;
+use proxmox_backup::client::{
+ http_client::{HttpClient, HttpClientOptions},
+ task_log::display_task_log,
+};
use proxmox_backup::tools::ticket::*;
use proxmox_backup::auth_helpers::*;
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 75f53b9b..9bb4c459 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -467,7 +467,11 @@ async fn schedule_datastore_sync_jobs() {
use proxmox_backup::{
backup::DataStore,
- client::{ HttpClient, HttpClientOptions, BackupRepository, pull::pull_store },
+ client::{
+ backup_repo::BackupRepository,
+ http_client::{HttpClient, HttpClientOptions},
+ pull::pull_store
+ },
server::{ WorkerTask },
config::{ sync::{self, SyncJobConfig}, remote::{self, Remote} },
tools::systemd::time::{ parse_calendar_event, compute_next_event },
diff --git a/src/bin/proxmox_backup_client/benchmark.rs b/src/bin/proxmox_backup_client/benchmark.rs
index 6392f282..1b42aff0 100644
--- a/src/bin/proxmox_backup_client/benchmark.rs
+++ b/src/bin/proxmox_backup_client/benchmark.rs
@@ -24,7 +24,7 @@ use proxmox_backup::backup::{
KeyDerivationConfig,
};
-use proxmox_backup::client::*;
+use proxmox_backup::client::{backup_repo::BackupRepository, backup_writer::BackupWriter};
use crate::{
KEYFILE_SCHEMA, REPO_URL_SCHEMA,
diff --git a/src/bin/proxmox_backup_client/catalog.rs b/src/bin/proxmox_backup_client/catalog.rs
index 1c0865e6..f9f88c87 100644
--- a/src/bin/proxmox_backup_client/catalog.rs
+++ b/src/bin/proxmox_backup_client/catalog.rs
@@ -9,7 +9,7 @@ use proxmox::api::{api, cli::*};
use proxmox_backup::tools;
-use proxmox_backup::client::*;
+use proxmox_backup::client::{backup_reader::BackupReader, remote_chunk_reader::RemoteChunkReader};
use crate::{
REPO_URL_SCHEMA,
diff --git a/src/bin/proxmox_backup_client/mount.rs b/src/bin/proxmox_backup_client/mount.rs
index 73bb8d4c..40af1740 100644
--- a/src/bin/proxmox_backup_client/mount.rs
+++ b/src/bin/proxmox_backup_client/mount.rs
@@ -25,7 +25,7 @@ use proxmox_backup::backup::{
BufferedDynamicReader,
};
-use proxmox_backup::client::*;
+use proxmox_backup::client::{backup_reader::BackupReader, remote_chunk_reader::RemoteChunkReader};
use crate::{
REPO_URL_SCHEMA,
diff --git a/src/bin/proxmox_backup_client/task.rs b/src/bin/proxmox_backup_client/task.rs
index 96a28be9..55b58949 100644
--- a/src/bin/proxmox_backup_client/task.rs
+++ b/src/bin/proxmox_backup_client/task.rs
@@ -5,7 +5,7 @@ use proxmox::api::{api, cli::*};
use proxmox_backup::tools;
-use proxmox_backup::client::*;
+use proxmox_backup::client::task_log::display_task_log;
use proxmox_backup::api2::types::UPID_SCHEMA;
use crate::{
diff --git a/src/client.rs b/src/client.rs
index 3fb01f8a..9f649685 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -6,28 +6,20 @@
mod merge_known_chunks;
pub mod pipe_to_stream;
-mod http_client;
-pub use http_client::*;
+pub mod http_client;
-mod task_log;
-pub use task_log::*;
+pub mod task_log;
-mod backup_reader;
-pub use backup_reader::*;
+pub mod backup_reader;
-mod backup_writer;
-pub use backup_writer::*;
+pub mod backup_writer;
-mod remote_chunk_reader;
-pub use remote_chunk_reader::*;
+pub mod remote_chunk_reader;
-mod pxar_backup_stream;
-pub use pxar_backup_stream::*;
+pub mod pxar_backup_stream;
-mod backup_repo;
-pub use backup_repo::*;
+pub mod backup_repo;
-mod backup_specification;
-pub use backup_specification::*;
+pub mod backup_specification;
pub mod pull;
diff --git a/src/client/backup_reader.rs b/src/client/backup_reader.rs
index b0b43c38..9e058a0b 100644
--- a/src/client/backup_reader.rs
+++ b/src/client/backup_reader.rs
@@ -12,7 +12,7 @@ use proxmox::tools::digest_to_hex;
use crate::backup::*;
-use super::{HttpClient, H2Client};
+use super::http_client::{HttpClient, H2Client};
/// Backup Reader
pub struct BackupReader {
diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
index 17c09d77..e073f627 100644
--- a/src/client/backup_writer.rs
+++ b/src/client/backup_writer.rs
@@ -17,7 +17,7 @@ use proxmox::tools::digest_to_hex;
use super::merge_known_chunks::{MergedChunkInfo, MergeKnownChunks};
use crate::backup::*;
-use super::{HttpClient, H2Client};
+use super::http_client::{HttpClient, H2Client};
pub struct BackupWriter {
h2: H2Client,
diff --git a/src/client/pull.rs b/src/client/pull.rs
index 5cf0dd1f..37e7b0c9 100644
--- a/src/client/pull.rs
+++ b/src/client/pull.rs
@@ -11,7 +11,10 @@ use chrono::{Utc, TimeZone};
use crate::server::{WorkerTask};
use crate::backup::*;
use crate::api2::types::*;
-use super::*;
+use super::backup_reader::{compute_file_csum, BackupReader};
+use super::backup_repo::BackupRepository;
+use super::http_client::{HttpClient, HttpClientOptions};
+use super::remote_chunk_reader::RemoteChunkReader;
// fixme: implement filters
diff --git a/src/client/remote_chunk_reader.rs b/src/client/remote_chunk_reader.rs
index eeb4851b..4e6583ee 100644
--- a/src/client/remote_chunk_reader.rs
+++ b/src/client/remote_chunk_reader.rs
@@ -5,7 +5,7 @@ use std::sync::{Arc, Mutex};
use anyhow::Error;
-use super::BackupReader;
+use super::backup_reader::BackupReader;
use crate::backup::{AsyncReadChunk, CryptConfig, DataBlob, ReadChunk};
use crate::tools::runtime::block_on;
diff --git a/src/client/task_log.rs b/src/client/task_log.rs
index 4db2a8e0..9d01537e 100644
--- a/src/client/task_log.rs
+++ b/src/client/task_log.rs
@@ -1,7 +1,7 @@
use anyhow::{bail, Error};
use serde_json::json;
-use super::HttpClient;
+use super::http_client::HttpClient;
pub async fn display_task_log(
client: HttpClient,
--
2.20.1
More information about the pbs-devel
mailing list