public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Mira Limbeck <m.limbeck@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] change * imports of proxmox_backup::client
Date: Fri, 17 Jul 2020 17:43:47 +0200	[thread overview]
Message-ID: <20200717154348.3406-1-m.limbeck@proxmox.com> (raw)

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@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





             reply	other threads:[~2020-07-17 15:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 15:43 Mira Limbeck [this message]
2020-07-17 15:43 ` [pbs-devel] [PATCH proxmox-backup 2/2] backup-client: change imports to not use '*' Mira Limbeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200717154348.3406-1-m.limbeck@proxmox.com \
    --to=m.limbeck@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal