[pbs-devel] [PATCH proxmox 1/2] split out compression code into new crate 'proxmox-compression'

Dominik Csapak d.csapak at proxmox.com
Fri Feb 18 13:48:48 CET 2022


this removes quite a bit of dependecies of proxmox-async.
while moving, remove the single use of io_format_err, so that
the crate has not to depend on 'proxmox_sys'

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 Cargo.toml                                    |  1 +
 Makefile                                      |  1 +
 proxmox-async/Cargo.toml                      |  8 +--
 proxmox-async/src/lib.rs                      |  2 -
 proxmox-compression/Cargo.toml                | 26 +++++++++
 proxmox-compression/debian/changelog          |  5 ++
 proxmox-compression/debian/control            | 56 +++++++++++++++++++
 proxmox-compression/debian/copyright          | 16 ++++++
 proxmox-compression/debian/debcargo.toml      |  7 +++
 .../src/compression.rs                        |  6 +-
 proxmox-compression/src/lib.rs                |  4 ++
 .../src/zip.rs                                |  2 +-
 12 files changed, 122 insertions(+), 12 deletions(-)
 create mode 100644 proxmox-compression/Cargo.toml
 create mode 100644 proxmox-compression/debian/changelog
 create mode 100644 proxmox-compression/debian/control
 create mode 100644 proxmox-compression/debian/copyright
 create mode 100644 proxmox-compression/debian/debcargo.toml
 rename {proxmox-async => proxmox-compression}/src/compression.rs (96%)
 create mode 100644 proxmox-compression/src/lib.rs
 rename {proxmox-async => proxmox-compression}/src/zip.rs (99%)

diff --git a/Cargo.toml b/Cargo.toml
index 4a458d2..a992dd0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,6 +3,7 @@ members = [
     "proxmox-api-macro",
     "proxmox-async",
     "proxmox-borrow",
+    "proxmox-compression",
     "proxmox-http",
     "proxmox-io",
     "proxmox-lang",
diff --git a/Makefile b/Makefile
index e4b08a3..8c72c65 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ CRATES = \
 	 proxmox-api-macro \
 	 proxmox-async \
 	 proxmox-borrow \
+	 proxmox-compression \
 	 proxmox-http \
 	 proxmox-io \
 	 proxmox-lang \
diff --git a/proxmox-async/Cargo.toml b/proxmox-async/Cargo.toml
index 291ff32..c7f78cc 100644
--- a/proxmox-async/Cargo.toml
+++ b/proxmox-async/Cargo.toml
@@ -10,19 +10,13 @@ exclude = [ "debian" ]
 
 [dependencies]
 anyhow = "1.0"
-bytes = "1.0"
-crc32fast = "1"
-endian_trait = { version = "0.6", features = ["arrays"] }
-flate2 = "1.0"
 futures = "0.3"
 lazy_static = "1.4"
 pin-utils = "0.1.0"
-tokio = { version = "1.0", features = ["fs", "net", "rt", "rt-multi-thread", "sync"] }
-walkdir = "2"
+tokio = { version = "1.0", features = [ "net", "rt", "rt-multi-thread", "sync"] }
 
 proxmox-sys = { path = "../proxmox-sys", version = "0.2.0" }
 proxmox-io = { path = "../proxmox-io", version = "1", features = [ "tokio" ] }
-proxmox-time = { path = "../proxmox-time", version = "1" }
 
 [dev-dependencies]
 tokio = { version = "1.6", features = [ "macros" ] }
diff --git a/proxmox-async/src/lib.rs b/proxmox-async/src/lib.rs
index ad540d3..5445f68 100644
--- a/proxmox-async/src/lib.rs
+++ b/proxmox-async/src/lib.rs
@@ -1,8 +1,6 @@
 pub mod blocking;
 pub mod broadcast_future;
-pub mod compression;
 pub mod io;
 pub mod net;
 pub mod runtime;
 pub mod stream;
-pub mod zip;
diff --git a/proxmox-compression/Cargo.toml b/proxmox-compression/Cargo.toml
new file mode 100644
index 0000000..6fa69fd
--- /dev/null
+++ b/proxmox-compression/Cargo.toml
@@ -0,0 +1,26 @@
+[package]
+name = "proxmox-compression"
+version = "0.1.0"
+authors = ["Proxmox Support Team <support at proxmox.com>"]
+edition = "2018"
+license = "AGPL-3"
+description = "contains compression utilitites (such as an Zip Encoder for async rust)"
+
+exclude = [ "debian" ]
+
+[dependencies]
+anyhow = "1.0"
+bytes = "1.0"
+crc32fast = "1"
+endian_trait = { version = "0.6" }
+flate2 = "1.0"
+futures = "0.3"
+tokio = { version = "1.6", features = [ "fs", "io-util"] }
+walkdir = "2"
+
+proxmox-time = { path = "../proxmox-time", version = "1" }
+proxmox-io = { path = "../proxmox-io", version = "1", features = [ "tokio" ] }
+
+[dev-dependencies]
+tokio = { version = "1.6", features = [ "macros" ] }
+
diff --git a/proxmox-compression/debian/changelog b/proxmox-compression/debian/changelog
new file mode 100644
index 0000000..3c81e27
--- /dev/null
+++ b/proxmox-compression/debian/changelog
@@ -0,0 +1,5 @@
+rust-proxmox-compression (0.1.0-1) stable; urgency=medium
+
+  * initial split out of `proxmox-async`
+
+ -- Proxmox Support Team <support at proxmox.com>  Fri, 18 Feb 2022 11:59:30 +0100
diff --git a/proxmox-compression/debian/control b/proxmox-compression/debian/control
new file mode 100644
index 0000000..12fa4e6
--- /dev/null
+++ b/proxmox-compression/debian/control
@@ -0,0 +1,56 @@
+Source: rust-proxmox-compression
+Section: rust
+Priority: optional
+Build-Depends: debhelper (>= 12),
+ dh-cargo (>= 25),
+ cargo:native <!nocheck>,
+ rustc:native <!nocheck>,
+ libstd-rust-dev <!nocheck>,
+ librust-anyhow-1+default-dev <!nocheck>,
+ librust-bytes-1+default-dev <!nocheck>,
+ librust-crc32fast-1+default-dev <!nocheck>,
+ librust-endian-trait-0.6+default-dev <!nocheck>,
+ librust-flate2-1+default-dev <!nocheck>,
+ librust-futures-0.3+default-dev <!nocheck>,
+ librust-proxmox-io-1+default-dev <!nocheck>,
+ librust-proxmox-io-1+tokio-dev <!nocheck>,
+ librust-proxmox-time-1+default-dev <!nocheck>,
+ librust-tokio-1+default-dev <!nocheck>,
+ librust-tokio-1+fs-dev <!nocheck>,
+ librust-tokio-1+io-util-dev <!nocheck>,
+ librust-walkdir-2+default-dev <!nocheck>
+Maintainer: Proxmox Support Team <support at proxmox.com>
+Standards-Version: 4.5.1
+Vcs-Git: git://git.proxmox.com/git/proxmox.git
+Vcs-Browser: https://git.proxmox.com/?p=proxmox.git
+Rules-Requires-Root: no
+
+Package: librust-proxmox-compression-dev
+Architecture: any
+Multi-Arch: same
+Depends:
+ ${misc:Depends},
+ librust-anyhow-1+default-dev,
+ librust-bytes-1+default-dev,
+ librust-crc32fast-1+default-dev,
+ librust-endian-trait-0.6+default-dev,
+ librust-flate2-1+default-dev,
+ librust-futures-0.3+default-dev,
+ librust-proxmox-io-1+default-dev,
+ librust-proxmox-io-1+tokio-dev,
+ librust-proxmox-time-1+default-dev,
+ librust-tokio-1+default-dev,
+ librust-tokio-1+fs-dev,
+ librust-tokio-1+io-util-dev,
+ librust-walkdir-2+default-dev
+Provides:
+ librust-proxmox-compression+default-dev (= ${binary:Version}),
+ librust-proxmox-compression-0-dev (= ${binary:Version}),
+ librust-proxmox-compression-0+default-dev (= ${binary:Version}),
+ librust-proxmox-compression-0.1-dev (= ${binary:Version}),
+ librust-proxmox-compression-0.1+default-dev (= ${binary:Version}),
+ librust-proxmox-compression-0.1.0-dev (= ${binary:Version}),
+ librust-proxmox-compression-0.1.0+default-dev (= ${binary:Version})
+Description: Contains compression utilitites (such as an Zip Encoder for async rust) - Rust source code
+ This package contains the source for the Rust proxmox-compression crate,
+ packaged by debcargo for use with cargo and dh-cargo.
diff --git a/proxmox-compression/debian/copyright b/proxmox-compression/debian/copyright
new file mode 100644
index 0000000..d2d30fc
--- /dev/null
+++ b/proxmox-compression/debian/copyright
@@ -0,0 +1,16 @@
+Copyright (C) 2022 Proxmox Server Solutions GmbH
+
+This software is written by Proxmox Server Solutions GmbH <support at proxmox.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
diff --git a/proxmox-compression/debian/debcargo.toml b/proxmox-compression/debian/debcargo.toml
new file mode 100644
index 0000000..b7864cd
--- /dev/null
+++ b/proxmox-compression/debian/debcargo.toml
@@ -0,0 +1,7 @@
+overlay = "."
+crate_src_path = ".."
+maintainer = "Proxmox Support Team <support at proxmox.com>"
+
+[source]
+vcs_git = "git://git.proxmox.com/git/proxmox.git"
+vcs_browser = "https://git.proxmox.com/?p=proxmox.git"
diff --git a/proxmox-async/src/compression.rs b/proxmox-compression/src/compression.rs
similarity index 96%
rename from proxmox-async/src/compression.rs
rename to proxmox-compression/src/compression.rs
index b36f291..a9837c7 100644
--- a/proxmox-async/src/compression.rs
+++ b/proxmox-compression/src/compression.rs
@@ -10,7 +10,6 @@ use futures::stream::Stream;
 use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
 
 use proxmox_io::ByteBuffer;
-use proxmox_sys::io_format_err;
 
 const BUFFER_SIZE: usize = 8192;
 
@@ -165,7 +164,10 @@ where
                 }
                 EncoderState::Writing => {
                     if this.input_buffer.is_empty() {
-                        return Poll::Ready(Some(Err(io_format_err!("empty input during write"))));
+                        return Poll::Ready(Some(Err(std::io::Error::new(
+                            std::io::ErrorKind::Other,
+                            "empty input during write",
+                        ))));
                     }
                     let mut buf = this.input_buffer.split_off(0);
                     let (read, res) = this.encode(&buf[..], FlushCompress::None)?;
diff --git a/proxmox-compression/src/lib.rs b/proxmox-compression/src/lib.rs
new file mode 100644
index 0000000..05cf06b
--- /dev/null
+++ b/proxmox-compression/src/lib.rs
@@ -0,0 +1,4 @@
+mod compression;
+pub use compression::*;
+
+pub mod zip;
diff --git a/proxmox-async/src/zip.rs b/proxmox-compression/src/zip.rs
similarity index 99%
rename from proxmox-async/src/zip.rs
rename to proxmox-compression/src/zip.rs
index 04bd4e0..a84c1c9 100644
--- a/proxmox-async/src/zip.rs
+++ b/proxmox-compression/src/zip.rs
@@ -437,7 +437,7 @@ where
 /// use anyhow::{Error, Result};
 /// use tokio::fs::File;
 ///
-/// use proxmox_async::zip::{ZipEncoder, ZipEntry};
+/// use proxmox_compression::zip::{ZipEncoder, ZipEntry};
 ///
 /// #[tokio::main]
 /// async fn main() -> Result<(), Error> {
-- 
2.30.2






More information about the pbs-devel mailing list