diff --git a/proxmox/Cargo.toml b/proxmox/Cargo.toml index 67fa98af..303e4f45 100644 --- a/proxmox/Cargo.toml +++ b/proxmox/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "proxmox" edition = "2018" -version = "0.13.5" +version = "0.14.0" authors = [ "Dietmar Maurer ", "Wolfgang Bumiller ", ] license = "AGPL-3" -description = "Proxmox library" +description = "Generic Proxmox library" exclude = [ "debian" ] @@ -30,6 +30,14 @@ tokio = { version = "1.0", features = [], optional = true } # Macro crates: proxmox-sortable-macro = { path = "../proxmox-sortable-macro", optional = true, version = "0.1.1" } +proxmox-io = { path = "../proxmox-io", version = "1.0.0" } +proxmox-lang = { path = "../proxmox-lang", version = "1.0.0" } +proxmox-schema = { path = "../proxmox-schema", version = "1.0.0" } +proxmox-time = { path = "../proxmox-time", version = "1.0.0" } + +[dev-dependencies] +tokio = "1.0" + [features] default = [] sortable-macro = ["proxmox-sortable-macro"] diff --git a/proxmox/debian/changelog b/proxmox/debian/changelog index 2c93505d..b7495f6b 100644 --- a/proxmox/debian/changelog +++ b/proxmox/debian/changelog @@ -1,3 +1,18 @@ +rust-proxmox (0.14.0-1) stable; urgency=medium + + * remove several modules moved into their own crates: + - borrow + - io + - lang + - router + - schema + - section-config + - tfa + - time + - uuid + + -- Proxmox Support Team Fri, 08 Oct 2021 08:37:11 +0200 + rust-proxmox (0.13.5-1) stable; urgency=medium * ParameterError: record parameter names diff --git a/proxmox/debian/control b/proxmox/debian/control index c5a78ae9..2d560d0b 100644 --- a/proxmox/debian/control +++ b/proxmox/debian/control @@ -7,32 +7,21 @@ Build-Depends: debhelper (>= 12), rustc:native , libstd-rust-dev , librust-anyhow-1+default-dev , - librust-base32-0.4+default-dev , librust-base64-0.12+default-dev , - librust-bytes-1+default-dev , librust-endian-trait-0.6+arrays-dev , librust-endian-trait-0.6+default-dev , - librust-futures-0.3+default-dev , - librust-http-0.2+default-dev , - librust-hyper-0.14+default-dev , - librust-hyper-0.14+full-dev , librust-lazy-static-1+default-dev (>= 1.4-~~) , librust-libc-0.2+default-dev , librust-nix-0.19+default-dev (>= 0.19.1-~~) , - librust-openssl-0.10+default-dev , - librust-percent-encoding-2+default-dev (>= 2.1-~~) , + librust-proxmox-io-1+default-dev , + librust-proxmox-lang-1+default-dev , + librust-proxmox-schema-1+default-dev , + librust-proxmox-time-1+default-dev , librust-regex-1+default-dev (>= 1.2-~~) , - librust-rustyline-7+default-dev , librust-serde-1+default-dev , librust-serde-1+derive-dev , librust-serde-json-1+default-dev , - librust-textwrap-0.11+default-dev , - librust-tokio-1+default-dev , librust-unicode-width-0.1+default-dev (>= 0.1.8-~~) , - librust-url-2+default-dev (>= 2.1-~~) , - uuid-dev , - uuid-dev , - uuid-dev , uuid-dev Maintainer: Proxmox Support Team Standards-Version: 4.5.1 @@ -47,195 +36,36 @@ Depends: ${misc:Depends}, librust-anyhow-1+default-dev, librust-base64-0.12+default-dev, - librust-bytes-1+default-dev, librust-endian-trait-0.6+arrays-dev, librust-endian-trait-0.6+default-dev, - librust-http-0.2+default-dev, librust-lazy-static-1+default-dev (>= 1.4-~~), librust-libc-0.2+default-dev, librust-nix-0.19+default-dev (>= 0.19.1-~~), - librust-percent-encoding-2+default-dev (>= 2.1-~~), + librust-proxmox-io-1+default-dev, + librust-proxmox-lang-1+default-dev, + librust-proxmox-schema-1+default-dev, + librust-proxmox-time-1+default-dev, librust-regex-1+default-dev (>= 1.2-~~), - librust-rustyline-7+default-dev, librust-serde-1+default-dev, librust-serde-1+derive-dev, librust-serde-json-1+default-dev, - librust-textwrap-0.11+default-dev, librust-unicode-width-0.1+default-dev (>= 0.1.8-~~), - librust-url-2+default-dev (>= 2.1-~~), uuid-dev -Recommends: - librust-proxmox+default-dev (= ${binary:Version}) Suggests: - librust-proxmox+api-macro-dev (= ${binary:Version}), - librust-proxmox+base32-dev (= ${binary:Version}), - librust-proxmox+cli-dev (= ${binary:Version}), - librust-proxmox+examples-dev (= ${binary:Version}), - librust-proxmox+futures-dev (= ${binary:Version}), - librust-proxmox+hyper-dev (= ${binary:Version}), - librust-proxmox+openssl-dev (= ${binary:Version}), librust-proxmox+proxmox-sortable-macro-dev (= ${binary:Version}), - librust-proxmox+router-dev (= ${binary:Version}), - librust-proxmox+tokio-dev (= ${binary:Version}), - librust-proxmox+tokio-stream-dev (= ${binary:Version}) + librust-proxmox+tokio-dev (= ${binary:Version}) Provides: - librust-proxmox+test-harness-dev (= ${binary:Version}), + librust-proxmox+default-dev (= ${binary:Version}), librust-proxmox-0-dev (= ${binary:Version}), - librust-proxmox-0+test-harness-dev (= ${binary:Version}), - librust-proxmox-0.13-dev (= ${binary:Version}), - librust-proxmox-0.13+test-harness-dev (= ${binary:Version}), - librust-proxmox-0.13.5-dev (= ${binary:Version}), - librust-proxmox-0.13.5+test-harness-dev (= ${binary:Version}) -Description: Proxmox library - Rust source code + librust-proxmox-0+default-dev (= ${binary:Version}), + librust-proxmox-0.14-dev (= ${binary:Version}), + librust-proxmox-0.14+default-dev (= ${binary:Version}), + librust-proxmox-0.14.0-dev (= ${binary:Version}), + librust-proxmox-0.14.0+default-dev (= ${binary:Version}) +Description: Generic Proxmox library - Rust source code This package contains the source for the Rust proxmox crate, packaged by debcargo for use with cargo and dh-cargo. -Package: librust-proxmox+api-macro-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-proxmox-api-macro-0.5+default-dev (>= 0.5.1-~~) -Provides: - librust-proxmox+proxmox-api-macro-dev (= ${binary:Version}), - librust-proxmox-0+api-macro-dev (= ${binary:Version}), - librust-proxmox-0+proxmox-api-macro-dev (= ${binary:Version}), - librust-proxmox-0.13+api-macro-dev (= ${binary:Version}), - librust-proxmox-0.13+proxmox-api-macro-dev (= ${binary:Version}), - librust-proxmox-0.13.5+api-macro-dev (= ${binary:Version}), - librust-proxmox-0.13.5+proxmox-api-macro-dev (= ${binary:Version}) -Description: Proxmox library - feature "api-macro" and 1 more - This metapackage enables feature "api-macro" for the Rust proxmox crate, by - pulling in any additional dependencies needed by that feature. - . - Additionally, this package also provides the "proxmox-api-macro" feature. - -Package: librust-proxmox+base32-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-base32-0.4+default-dev -Provides: - librust-proxmox+u2f-dev (= ${binary:Version}), - librust-proxmox-0+base32-dev (= ${binary:Version}), - librust-proxmox-0+u2f-dev (= ${binary:Version}), - librust-proxmox-0.13+base32-dev (= ${binary:Version}), - librust-proxmox-0.13+u2f-dev (= ${binary:Version}), - librust-proxmox-0.13.5+base32-dev (= ${binary:Version}), - librust-proxmox-0.13.5+u2f-dev (= ${binary:Version}) -Description: Proxmox library - feature "base32" and 1 more - This metapackage enables feature "base32" for the Rust proxmox crate, by - pulling in any additional dependencies needed by that feature. - . - Additionally, this package also provides the "u2f" feature. - -Package: librust-proxmox+cli-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-proxmox+router-dev (= ${binary:Version}), - librust-hyper-0.14+default-dev, - librust-hyper-0.14+full-dev, - librust-tokio-1+default-dev -Provides: - librust-proxmox-0+cli-dev (= ${binary:Version}), - librust-proxmox-0.13+cli-dev (= ${binary:Version}), - librust-proxmox-0.13.5+cli-dev (= ${binary:Version}) -Description: Proxmox library - feature "cli" - This metapackage enables feature "cli" for the Rust proxmox crate, by pulling - in any additional dependencies needed by that feature. - -Package: librust-proxmox+default-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-proxmox+cli-dev (= ${binary:Version}), - librust-proxmox+router-dev (= ${binary:Version}), - librust-proxmox+tfa-dev (= ${binary:Version}), - librust-proxmox+u2f-dev (= ${binary:Version}) -Provides: - librust-proxmox-0+default-dev (= ${binary:Version}), - librust-proxmox-0.13+default-dev (= ${binary:Version}), - librust-proxmox-0.13.5+default-dev (= ${binary:Version}) -Description: Proxmox library - feature "default" - This metapackage enables feature "default" for the Rust proxmox crate, by - pulling in any additional dependencies needed by that feature. - -Package: librust-proxmox+examples-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-proxmox+u2f-dev (= ${binary:Version}), - librust-tokio-1+macros-dev -Provides: - librust-proxmox-0+examples-dev (= ${binary:Version}), - librust-proxmox-0.13+examples-dev (= ${binary:Version}), - librust-proxmox-0.13.5+examples-dev (= ${binary:Version}) -Description: Proxmox library - feature "examples" - This metapackage enables feature "examples" for the Rust proxmox crate, by - pulling in any additional dependencies needed by that feature. - -Package: librust-proxmox+futures-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-futures-0.3+default-dev -Provides: - librust-proxmox-0+futures-dev (= ${binary:Version}), - librust-proxmox-0.13+futures-dev (= ${binary:Version}), - librust-proxmox-0.13.5+futures-dev (= ${binary:Version}) -Description: Proxmox library - feature "futures" - This metapackage enables feature "futures" for the Rust proxmox crate, by - pulling in any additional dependencies needed by that feature. - -Package: librust-proxmox+hyper-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-hyper-0.14+default-dev, - librust-hyper-0.14+full-dev -Provides: - librust-proxmox-0+hyper-dev (= ${binary:Version}), - librust-proxmox-0.13+hyper-dev (= ${binary:Version}), - librust-proxmox-0.13.5+hyper-dev (= ${binary:Version}) -Description: Proxmox library - feature "hyper" - This metapackage enables feature "hyper" for the Rust proxmox crate, by pulling - in any additional dependencies needed by that feature. - -Package: librust-proxmox+openssl-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-openssl-0.10+default-dev -Provides: - librust-proxmox+tfa-dev (= ${binary:Version}), - librust-proxmox-0+openssl-dev (= ${binary:Version}), - librust-proxmox-0+tfa-dev (= ${binary:Version}), - librust-proxmox-0.13+openssl-dev (= ${binary:Version}), - librust-proxmox-0.13+tfa-dev (= ${binary:Version}), - librust-proxmox-0.13.5+openssl-dev (= ${binary:Version}), - librust-proxmox-0.13.5+tfa-dev (= ${binary:Version}) -Description: Proxmox library - feature "openssl" and 1 more - This metapackage enables feature "openssl" for the Rust proxmox crate, by - pulling in any additional dependencies needed by that feature. - . - Additionally, this package also provides the "tfa" feature. - Package: librust-proxmox+proxmox-sortable-macro-dev Architecture: any Multi-Arch: same @@ -247,34 +77,16 @@ Provides: librust-proxmox+sortable-macro-dev (= ${binary:Version}), librust-proxmox-0+proxmox-sortable-macro-dev (= ${binary:Version}), librust-proxmox-0+sortable-macro-dev (= ${binary:Version}), - librust-proxmox-0.13+proxmox-sortable-macro-dev (= ${binary:Version}), - librust-proxmox-0.13+sortable-macro-dev (= ${binary:Version}), - librust-proxmox-0.13.5+proxmox-sortable-macro-dev (= ${binary:Version}), - librust-proxmox-0.13.5+sortable-macro-dev (= ${binary:Version}) -Description: Proxmox library - feature "proxmox-sortable-macro" and 1 more + librust-proxmox-0.14+proxmox-sortable-macro-dev (= ${binary:Version}), + librust-proxmox-0.14+sortable-macro-dev (= ${binary:Version}), + librust-proxmox-0.14.0+proxmox-sortable-macro-dev (= ${binary:Version}), + librust-proxmox-0.14.0+sortable-macro-dev (= ${binary:Version}) +Description: Generic Proxmox library - feature "proxmox-sortable-macro" and 1 more This metapackage enables feature "proxmox-sortable-macro" for the Rust proxmox crate, by pulling in any additional dependencies needed by that feature. . Additionally, this package also provides the "sortable-macro" feature. -Package: librust-proxmox+router-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-futures-0.3+default-dev, - librust-hyper-0.14+default-dev, - librust-hyper-0.14+full-dev, - librust-tokio-1+default-dev -Provides: - librust-proxmox-0+router-dev (= ${binary:Version}), - librust-proxmox-0.13+router-dev (= ${binary:Version}), - librust-proxmox-0.13.5+router-dev (= ${binary:Version}) -Description: Proxmox library - feature "router" - This metapackage enables feature "router" for the Rust proxmox crate, by - pulling in any additional dependencies needed by that feature. - Package: librust-proxmox+tokio-dev Architecture: any Multi-Arch: same @@ -284,23 +96,8 @@ Depends: librust-tokio-1+default-dev Provides: librust-proxmox-0+tokio-dev (= ${binary:Version}), - librust-proxmox-0.13+tokio-dev (= ${binary:Version}), - librust-proxmox-0.13.5+tokio-dev (= ${binary:Version}) -Description: Proxmox library - feature "tokio" + librust-proxmox-0.14+tokio-dev (= ${binary:Version}), + librust-proxmox-0.14.0+tokio-dev (= ${binary:Version}) +Description: Generic Proxmox library - feature "tokio" This metapackage enables feature "tokio" for the Rust proxmox crate, by pulling in any additional dependencies needed by that feature. - -Package: librust-proxmox+tokio-stream-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-tokio-stream-0.1+default-dev (>= 0.1.1-~~) -Provides: - librust-proxmox-0+tokio-stream-dev (= ${binary:Version}), - librust-proxmox-0.13+tokio-stream-dev (= ${binary:Version}), - librust-proxmox-0.13.5+tokio-stream-dev (= ${binary:Version}) -Description: Proxmox library - feature "tokio-stream" - This metapackage enables feature "tokio-stream" for the Rust proxmox crate, by - pulling in any additional dependencies needed by that feature. diff --git a/proxmox/src/lib.rs b/proxmox/src/lib.rs index 8d6bcfcf..88bdbc01 100644 --- a/proxmox/src/lib.rs +++ b/proxmox/src/lib.rs @@ -7,9 +7,6 @@ pub mod serde_macros; pub mod sys; pub mod tools; -#[cfg(test)] -pub mod test; - /// An identity (nop) macro. Used by the `#[sortable]` proc macro. #[cfg(feature = "sortable-macro")] #[macro_export] diff --git a/proxmox/src/sys/linux/mod.rs b/proxmox/src/sys/linux/mod.rs index ccd710c9..311c9d56 100644 --- a/proxmox/src/sys/linux/mod.rs +++ b/proxmox/src/sys/linux/mod.rs @@ -2,6 +2,8 @@ use anyhow::*; +use proxmox_io::vec; + pub mod magic; pub mod pid; pub mod procfs; @@ -11,7 +13,7 @@ pub mod tty; /// Get pseudo random data (/dev/urandom) pub fn random_data(size: usize) -> Result, Error> { - let mut buffer = crate::tools::vec::undefined(size); + let mut buffer = vec::undefined(size); fill_with_random_data(&mut buffer)?; Ok(buffer) diff --git a/proxmox/src/sys/linux/pid.rs b/proxmox/src/sys/linux/pid.rs index 534a3c28..3e4a256a 100644 --- a/proxmox/src/sys/linux/pid.rs +++ b/proxmox/src/sys/linux/pid.rs @@ -11,10 +11,12 @@ use nix::sys::stat::Mode; use nix::unistd::Pid; use nix::NixPath; +use proxmox_lang::c_str; + use crate::sys::error::{io_err_other, SysResult}; use crate::sys::linux::procfs::{MountInfo, PidStat}; use crate::tools::fd::Fd; -use crate::{c_result, c_str, c_try}; +use crate::{c_result, c_try}; /// asm-generic pidfd_open syscall number #[allow(non_upper_case_globals)] diff --git a/proxmox/src/sys/linux/tty.rs b/proxmox/src/sys/linux/tty.rs index ee8ad577..0b4a3c14 100644 --- a/proxmox/src/sys/linux/tty.rs +++ b/proxmox/src/sys/linux/tty.rs @@ -6,9 +6,11 @@ use anyhow::*; use nix::fcntl::OFlag; use nix::sys::stat::Mode; +use proxmox_lang::try_block; + +use crate::c_try; use crate::sys::error::SysError; use crate::tools::fd::Fd; -use crate::{c_try, try_block}; /// Get the current size of the terminal (for stdout). /// # Safety diff --git a/proxmox/src/test/io.rs b/proxmox/src/test/io.rs deleted file mode 100644 index 6e4a2782..00000000 --- a/proxmox/src/test/io.rs +++ /dev/null @@ -1,87 +0,0 @@ -use std::pin::Pin; -use std::task::{Context, Poll}; - -use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite, ReadBuf}; - -pub struct AsyncBlockingReader { - inner: R, -} - -impl AsyncBlockingReader { - pub fn new(inner: W) -> Self { - Self { inner } - } - - pub fn inner(&self) -> &W { - &self.inner - } -} - -pub struct AsyncBlockingWriter { - inner: W, - seek_pos: u64, -} - -impl AsyncBlockingWriter { - pub fn new(inner: W) -> Self { - Self { inner, seek_pos: 0 } - } - - pub fn inner(&self) -> &W { - &self.inner - } -} - -impl AsyncRead for AsyncBlockingReader { - fn poll_read( - self: Pin<&mut Self>, - _cx: &mut Context<'_>, - buf: &mut ReadBuf<'_>, - ) -> Poll> { - let this = Pin::get_mut(self); - let mut read_buf = buf.initialize_unfilled(); - Poll::Ready(match this.inner.read(&mut read_buf) { - Ok(len) => { - buf.advance(len); - Ok(()) - } - Err(err) => Err(err), - }) - } -} - -impl AsyncWrite for AsyncBlockingWriter { - fn poll_write( - self: Pin<&mut Self>, - _cx: &mut Context<'_>, - buf: &[u8], - ) -> Poll> { - let this = Pin::get_mut(self); - Poll::Ready(match this.inner.write(buf) { - Ok(len) => Ok(len), - Err(err) => Err(err), - }) - } - - fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll> { - let this = Pin::get_mut(self); - Poll::Ready(this.inner.flush()) - } - - fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } -} - -impl AsyncSeek for AsyncBlockingWriter { - fn start_seek(self: Pin<&mut Self>, position: std::io::SeekFrom) -> std::io::Result<()> { - let this = Pin::get_mut(self); - this.seek_pos = this.inner.seek(position)?; - Ok(()) - } - - fn poll_complete(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll> { - let this = Pin::get_mut(self); - Poll::Ready(Ok(this.seek_pos)) - } -} diff --git a/proxmox/src/test/mod.rs b/proxmox/src/test/mod.rs deleted file mode 100644 index 5883d5ef..00000000 --- a/proxmox/src/test/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod io; -pub mod task; -mod schema; -mod schema_verification; diff --git a/proxmox/src/test/task.rs b/proxmox/src/test/task.rs deleted file mode 100644 index 62c22f39..00000000 --- a/proxmox/src/test/task.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::future::Future; -use std::pin::Pin; -use std::task::{Context, Poll}; - -pub fn poll_result_once(mut fut: T) -> std::io::Result -where - T: Future>, -{ - let waker = std::task::RawWaker::new(std::ptr::null(), &WAKER_VTABLE); - let waker = unsafe { std::task::Waker::from_raw(waker) }; - let mut cx = Context::from_waker(&waker); - unsafe { - match Pin::new_unchecked(&mut fut).poll(&mut cx) { - Poll::Pending => Err(crate::sys::error::io_err_other( - "got Poll::Pending synchronous context", - )), - Poll::Ready(r) => r, - } - } -} - -const WAKER_VTABLE: std::task::RawWakerVTable = - std::task::RawWakerVTable::new(forbid_clone, forbid_wake, forbid_wake, ignore_drop); - -unsafe fn forbid_clone(_: *const ()) -> std::task::RawWaker { - panic!("tried to clone waker for synchronous task"); -} - -unsafe fn forbid_wake(_: *const ()) { - panic!("tried to wake synchronous task"); -} -unsafe fn ignore_drop(_: *const ()) {} diff --git a/proxmox/src/tools/email.rs b/proxmox/src/tools/email.rs index 895d2b64..fcdf043a 100644 --- a/proxmox/src/tools/email.rs +++ b/proxmox/src/tools/email.rs @@ -1,10 +1,10 @@ //! Email related utilities. -use crate::tools::time::epoch_i64; -use anyhow::{bail, Error}; use std::io::Write; use std::process::{Command, Stdio}; +use anyhow::{bail, Error}; + /// Sends multi-part mail with text and/or html to a list of recipients /// /// ``sendmail`` is used for sending the mail. @@ -23,7 +23,7 @@ pub fn sendmail( let recipients = mailto.join(","); let author = author.unwrap_or("Proxmox Backup Server"); - let now = epoch_i64(); + let now = proxmox_time::epoch_i64(); let mut sendmail_process = match Command::new("/usr/sbin/sendmail") .arg("-B") @@ -62,8 +62,8 @@ pub fn sendmail( } body.push_str(&format!("From: {} <{}>\n", author, mailfrom)); body.push_str(&format!("To: {}\n", &recipients)); - let localtime = crate::tools::time::localtime(now)?; - let rfc2822_date = crate::tools::time::strftime("%a, %d %b %Y %T %z", &localtime)?; + let localtime = proxmox_time::localtime(now)?; + let rfc2822_date = proxmox_time::strftime("%a, %d %b %Y %T %z", &localtime)?; body.push_str(&format!("Date: {}\n", rfc2822_date)); if is_multipart { body.push('\n'); diff --git a/proxmox/src/tools/fs.rs b/proxmox/src/tools/fs.rs index 9d01aae1..19e549d6 100644 --- a/proxmox/src/tools/fs.rs +++ b/proxmox/src/tools/fs.rs @@ -15,10 +15,11 @@ use nix::unistd::{self, Gid, Uid}; use nix::NixPath; use serde_json::Value; +use proxmox_lang::try_block; + use crate::sys::error::{SysError, SysResult}; use crate::sys::timer; use crate::tools::fd::Fd; -use crate::try_block; /// Read the entire contents of a file into a bytes vector /// diff --git a/proxmox/src/tools/mod.rs b/proxmox/src/tools/mod.rs index 0ab8aed3..76b76d0a 100644 --- a/proxmox/src/tools/mod.rs +++ b/proxmox/src/tools/mod.rs @@ -2,9 +2,11 @@ use std::fmt; -use anyhow::*; +use anyhow::{bail, Error}; use lazy_static::lazy_static; +use proxmox_io::vec; + pub mod common_regex; pub mod email; pub mod fd; diff --git a/proxmox/src/tools/serde.rs b/proxmox/src/tools/serde.rs index 332774bd..6da63f61 100644 --- a/proxmox/src/tools/serde.rs +++ b/proxmox/src/tools/serde.rs @@ -29,7 +29,7 @@ pub mod epoch_as_rfc3339 { S: Serializer, { use serde::ser::Error; - let s = crate::tools::time::epoch_to_rfc3339(*epoch) + let s = proxmox_time::epoch_to_rfc3339(*epoch) .map_err(|err| Error::custom(err.to_string()))?; serializer.serialize_str(&s) @@ -41,7 +41,7 @@ pub mod epoch_as_rfc3339 { { use serde::de::Error; String::deserialize(deserializer).and_then(|string| { - crate::tools::time::parse_rfc3339(&string).map_err(|err| Error::custom(err.to_string())) + proxmox_time::parse_rfc3339(&string).map_err(|err| Error::custom(err.to_string())) }) } }