update proxmox crate to the current split

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-10-08 08:38:23 +02:00
parent 1d24555b28
commit 336dab0177
14 changed files with 70 additions and 367 deletions

View File

@ -1,13 +1,13 @@
[package] [package]
name = "proxmox" name = "proxmox"
edition = "2018" edition = "2018"
version = "0.13.5" version = "0.14.0"
authors = [ authors = [
"Dietmar Maurer <dietmar@proxmox.com>", "Dietmar Maurer <dietmar@proxmox.com>",
"Wolfgang Bumiller <w.bumiller@proxmox.com>", "Wolfgang Bumiller <w.bumiller@proxmox.com>",
] ]
license = "AGPL-3" license = "AGPL-3"
description = "Proxmox library" description = "Generic Proxmox library"
exclude = [ "debian" ] exclude = [ "debian" ]
@ -30,6 +30,14 @@ tokio = { version = "1.0", features = [], optional = true }
# Macro crates: # Macro crates:
proxmox-sortable-macro = { path = "../proxmox-sortable-macro", optional = true, version = "0.1.1" } 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] [features]
default = [] default = []
sortable-macro = ["proxmox-sortable-macro"] sortable-macro = ["proxmox-sortable-macro"]

View File

@ -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 <support@proxmox.com> Fri, 08 Oct 2021 08:37:11 +0200
rust-proxmox (0.13.5-1) stable; urgency=medium rust-proxmox (0.13.5-1) stable; urgency=medium
* ParameterError: record parameter names * ParameterError: record parameter names

View File

@ -7,32 +7,21 @@ Build-Depends: debhelper (>= 12),
rustc:native <!nocheck>, rustc:native <!nocheck>,
libstd-rust-dev <!nocheck>, libstd-rust-dev <!nocheck>,
librust-anyhow-1+default-dev <!nocheck>, librust-anyhow-1+default-dev <!nocheck>,
librust-base32-0.4+default-dev <!nocheck>,
librust-base64-0.12+default-dev <!nocheck>, librust-base64-0.12+default-dev <!nocheck>,
librust-bytes-1+default-dev <!nocheck>,
librust-endian-trait-0.6+arrays-dev <!nocheck>, librust-endian-trait-0.6+arrays-dev <!nocheck>,
librust-endian-trait-0.6+default-dev <!nocheck>, librust-endian-trait-0.6+default-dev <!nocheck>,
librust-futures-0.3+default-dev <!nocheck>,
librust-http-0.2+default-dev <!nocheck>,
librust-hyper-0.14+default-dev <!nocheck>,
librust-hyper-0.14+full-dev <!nocheck>,
librust-lazy-static-1+default-dev (>= 1.4-~~) <!nocheck>, librust-lazy-static-1+default-dev (>= 1.4-~~) <!nocheck>,
librust-libc-0.2+default-dev <!nocheck>, librust-libc-0.2+default-dev <!nocheck>,
librust-nix-0.19+default-dev (>= 0.19.1-~~) <!nocheck>, librust-nix-0.19+default-dev (>= 0.19.1-~~) <!nocheck>,
librust-openssl-0.10+default-dev <!nocheck>, librust-proxmox-io-1+default-dev <!nocheck>,
librust-percent-encoding-2+default-dev (>= 2.1-~~) <!nocheck>, librust-proxmox-lang-1+default-dev <!nocheck>,
librust-proxmox-schema-1+default-dev <!nocheck>,
librust-proxmox-time-1+default-dev <!nocheck>,
librust-regex-1+default-dev (>= 1.2-~~) <!nocheck>, librust-regex-1+default-dev (>= 1.2-~~) <!nocheck>,
librust-rustyline-7+default-dev <!nocheck>,
librust-serde-1+default-dev <!nocheck>, librust-serde-1+default-dev <!nocheck>,
librust-serde-1+derive-dev <!nocheck>, librust-serde-1+derive-dev <!nocheck>,
librust-serde-json-1+default-dev <!nocheck>, librust-serde-json-1+default-dev <!nocheck>,
librust-textwrap-0.11+default-dev <!nocheck>,
librust-tokio-1+default-dev <!nocheck>,
librust-unicode-width-0.1+default-dev (>= 0.1.8-~~) <!nocheck>, librust-unicode-width-0.1+default-dev (>= 0.1.8-~~) <!nocheck>,
librust-url-2+default-dev (>= 2.1-~~) <!nocheck>,
uuid-dev <!nocheck>,
uuid-dev <!nocheck>,
uuid-dev <!nocheck>,
uuid-dev <!nocheck> uuid-dev <!nocheck>
Maintainer: Proxmox Support Team <support@proxmox.com> Maintainer: Proxmox Support Team <support@proxmox.com>
Standards-Version: 4.5.1 Standards-Version: 4.5.1
@ -47,195 +36,36 @@ Depends:
${misc:Depends}, ${misc:Depends},
librust-anyhow-1+default-dev, librust-anyhow-1+default-dev,
librust-base64-0.12+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+arrays-dev,
librust-endian-trait-0.6+default-dev, librust-endian-trait-0.6+default-dev,
librust-http-0.2+default-dev,
librust-lazy-static-1+default-dev (>= 1.4-~~), librust-lazy-static-1+default-dev (>= 1.4-~~),
librust-libc-0.2+default-dev, librust-libc-0.2+default-dev,
librust-nix-0.19+default-dev (>= 0.19.1-~~), 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-regex-1+default-dev (>= 1.2-~~),
librust-rustyline-7+default-dev,
librust-serde-1+default-dev, librust-serde-1+default-dev,
librust-serde-1+derive-dev, librust-serde-1+derive-dev,
librust-serde-json-1+default-dev, librust-serde-json-1+default-dev,
librust-textwrap-0.11+default-dev,
librust-unicode-width-0.1+default-dev (>= 0.1.8-~~), librust-unicode-width-0.1+default-dev (>= 0.1.8-~~),
librust-url-2+default-dev (>= 2.1-~~),
uuid-dev uuid-dev
Recommends:
librust-proxmox+default-dev (= ${binary:Version})
Suggests: 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+proxmox-sortable-macro-dev (= ${binary:Version}),
librust-proxmox+router-dev (= ${binary:Version}), librust-proxmox+tokio-dev (= ${binary:Version})
librust-proxmox+tokio-dev (= ${binary:Version}),
librust-proxmox+tokio-stream-dev (= ${binary:Version})
Provides: Provides:
librust-proxmox+test-harness-dev (= ${binary:Version}), librust-proxmox+default-dev (= ${binary:Version}),
librust-proxmox-0-dev (= ${binary:Version}), librust-proxmox-0-dev (= ${binary:Version}),
librust-proxmox-0+test-harness-dev (= ${binary:Version}), librust-proxmox-0+default-dev (= ${binary:Version}),
librust-proxmox-0.13-dev (= ${binary:Version}), librust-proxmox-0.14-dev (= ${binary:Version}),
librust-proxmox-0.13+test-harness-dev (= ${binary:Version}), librust-proxmox-0.14+default-dev (= ${binary:Version}),
librust-proxmox-0.13.5-dev (= ${binary:Version}), librust-proxmox-0.14.0-dev (= ${binary:Version}),
librust-proxmox-0.13.5+test-harness-dev (= ${binary:Version}) librust-proxmox-0.14.0+default-dev (= ${binary:Version})
Description: Proxmox library - Rust source code Description: Generic Proxmox library - Rust source code
This package contains the source for the Rust proxmox crate, packaged by This package contains the source for the Rust proxmox crate, packaged by
debcargo for use with cargo and dh-cargo. 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 Package: librust-proxmox+proxmox-sortable-macro-dev
Architecture: any Architecture: any
Multi-Arch: same Multi-Arch: same
@ -247,34 +77,16 @@ Provides:
librust-proxmox+sortable-macro-dev (= ${binary:Version}), librust-proxmox+sortable-macro-dev (= ${binary:Version}),
librust-proxmox-0+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+sortable-macro-dev (= ${binary:Version}),
librust-proxmox-0.13+proxmox-sortable-macro-dev (= ${binary:Version}), librust-proxmox-0.14+proxmox-sortable-macro-dev (= ${binary:Version}),
librust-proxmox-0.13+sortable-macro-dev (= ${binary:Version}), librust-proxmox-0.14+sortable-macro-dev (= ${binary:Version}),
librust-proxmox-0.13.5+proxmox-sortable-macro-dev (= ${binary:Version}), librust-proxmox-0.14.0+proxmox-sortable-macro-dev (= ${binary:Version}),
librust-proxmox-0.13.5+sortable-macro-dev (= ${binary:Version}) librust-proxmox-0.14.0+sortable-macro-dev (= ${binary:Version})
Description: Proxmox library - feature "proxmox-sortable-macro" and 1 more Description: Generic Proxmox library - feature "proxmox-sortable-macro" and 1 more
This metapackage enables feature "proxmox-sortable-macro" for the Rust proxmox This metapackage enables feature "proxmox-sortable-macro" for the Rust proxmox
crate, by pulling in any additional dependencies needed by that feature. crate, by pulling in any additional dependencies needed by that feature.
. .
Additionally, this package also provides the "sortable-macro" 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 Package: librust-proxmox+tokio-dev
Architecture: any Architecture: any
Multi-Arch: same Multi-Arch: same
@ -284,23 +96,8 @@ Depends:
librust-tokio-1+default-dev librust-tokio-1+default-dev
Provides: Provides:
librust-proxmox-0+tokio-dev (= ${binary:Version}), librust-proxmox-0+tokio-dev (= ${binary:Version}),
librust-proxmox-0.13+tokio-dev (= ${binary:Version}), librust-proxmox-0.14+tokio-dev (= ${binary:Version}),
librust-proxmox-0.13.5+tokio-dev (= ${binary:Version}) librust-proxmox-0.14.0+tokio-dev (= ${binary:Version})
Description: Proxmox library - feature "tokio" Description: Generic Proxmox library - feature "tokio"
This metapackage enables feature "tokio" for the Rust proxmox crate, by pulling This metapackage enables feature "tokio" for the Rust proxmox crate, by pulling
in any additional dependencies needed by that feature. 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.

View File

@ -7,9 +7,6 @@ pub mod serde_macros;
pub mod sys; pub mod sys;
pub mod tools; pub mod tools;
#[cfg(test)]
pub mod test;
/// An identity (nop) macro. Used by the `#[sortable]` proc macro. /// An identity (nop) macro. Used by the `#[sortable]` proc macro.
#[cfg(feature = "sortable-macro")] #[cfg(feature = "sortable-macro")]
#[macro_export] #[macro_export]

View File

@ -2,6 +2,8 @@
use anyhow::*; use anyhow::*;
use proxmox_io::vec;
pub mod magic; pub mod magic;
pub mod pid; pub mod pid;
pub mod procfs; pub mod procfs;
@ -11,7 +13,7 @@ pub mod tty;
/// Get pseudo random data (/dev/urandom) /// Get pseudo random data (/dev/urandom)
pub fn random_data(size: usize) -> Result<Vec<u8>, Error> { pub fn random_data(size: usize) -> Result<Vec<u8>, Error> {
let mut buffer = crate::tools::vec::undefined(size); let mut buffer = vec::undefined(size);
fill_with_random_data(&mut buffer)?; fill_with_random_data(&mut buffer)?;
Ok(buffer) Ok(buffer)

View File

@ -11,10 +11,12 @@ use nix::sys::stat::Mode;
use nix::unistd::Pid; use nix::unistd::Pid;
use nix::NixPath; use nix::NixPath;
use proxmox_lang::c_str;
use crate::sys::error::{io_err_other, SysResult}; use crate::sys::error::{io_err_other, SysResult};
use crate::sys::linux::procfs::{MountInfo, PidStat}; use crate::sys::linux::procfs::{MountInfo, PidStat};
use crate::tools::fd::Fd; 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 /// asm-generic pidfd_open syscall number
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]

View File

@ -6,9 +6,11 @@ use anyhow::*;
use nix::fcntl::OFlag; use nix::fcntl::OFlag;
use nix::sys::stat::Mode; use nix::sys::stat::Mode;
use proxmox_lang::try_block;
use crate::c_try;
use crate::sys::error::SysError; use crate::sys::error::SysError;
use crate::tools::fd::Fd; use crate::tools::fd::Fd;
use crate::{c_try, try_block};
/// Get the current size of the terminal (for stdout). /// Get the current size of the terminal (for stdout).
/// # Safety /// # Safety

View File

@ -1,87 +0,0 @@
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite, ReadBuf};
pub struct AsyncBlockingReader<R> {
inner: R,
}
impl<W> AsyncBlockingReader<W> {
pub fn new(inner: W) -> Self {
Self { inner }
}
pub fn inner(&self) -> &W {
&self.inner
}
}
pub struct AsyncBlockingWriter<W> {
inner: W,
seek_pos: u64,
}
impl<W> AsyncBlockingWriter<W> {
pub fn new(inner: W) -> Self {
Self { inner, seek_pos: 0 }
}
pub fn inner(&self) -> &W {
&self.inner
}
}
impl<R: std::io::Read + Unpin> AsyncRead for AsyncBlockingReader<R> {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<std::io::Result<()>> {
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<R: std::io::Write + Unpin> AsyncWrite for AsyncBlockingWriter<R> {
fn poll_write(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<std::io::Result<usize>> {
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<std::io::Result<()>> {
let this = Pin::get_mut(self);
Poll::Ready(this.inner.flush())
}
fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
Poll::Ready(Ok(()))
}
}
impl<R: std::io::Seek + Unpin> AsyncSeek for AsyncBlockingWriter<R> {
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<std::io::Result<u64>> {
let this = Pin::get_mut(self);
Poll::Ready(Ok(this.seek_pos))
}
}

View File

@ -1,4 +0,0 @@
pub mod io;
pub mod task;
mod schema;
mod schema_verification;

View File

@ -1,32 +0,0 @@
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
pub fn poll_result_once<T, R>(mut fut: T) -> std::io::Result<R>
where
T: Future<Output = std::io::Result<R>>,
{
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 ()) {}

View File

@ -1,10 +1,10 @@
//! Email related utilities. //! Email related utilities.
use crate::tools::time::epoch_i64;
use anyhow::{bail, Error};
use std::io::Write; use std::io::Write;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use anyhow::{bail, Error};
/// Sends multi-part mail with text and/or html to a list of recipients /// Sends multi-part mail with text and/or html to a list of recipients
/// ///
/// ``sendmail`` is used for sending the mail. /// ``sendmail`` is used for sending the mail.
@ -23,7 +23,7 @@ pub fn sendmail(
let recipients = mailto.join(","); let recipients = mailto.join(",");
let author = author.unwrap_or("Proxmox Backup Server"); 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") let mut sendmail_process = match Command::new("/usr/sbin/sendmail")
.arg("-B") .arg("-B")
@ -62,8 +62,8 @@ pub fn sendmail(
} }
body.push_str(&format!("From: {} <{}>\n", author, mailfrom)); body.push_str(&format!("From: {} <{}>\n", author, mailfrom));
body.push_str(&format!("To: {}\n", &recipients)); body.push_str(&format!("To: {}\n", &recipients));
let localtime = crate::tools::time::localtime(now)?; let localtime = proxmox_time::localtime(now)?;
let rfc2822_date = crate::tools::time::strftime("%a, %d %b %Y %T %z", &localtime)?; let rfc2822_date = proxmox_time::strftime("%a, %d %b %Y %T %z", &localtime)?;
body.push_str(&format!("Date: {}\n", rfc2822_date)); body.push_str(&format!("Date: {}\n", rfc2822_date));
if is_multipart { if is_multipart {
body.push('\n'); body.push('\n');

View File

@ -15,10 +15,11 @@ use nix::unistd::{self, Gid, Uid};
use nix::NixPath; use nix::NixPath;
use serde_json::Value; use serde_json::Value;
use proxmox_lang::try_block;
use crate::sys::error::{SysError, SysResult}; use crate::sys::error::{SysError, SysResult};
use crate::sys::timer; use crate::sys::timer;
use crate::tools::fd::Fd; use crate::tools::fd::Fd;
use crate::try_block;
/// Read the entire contents of a file into a bytes vector /// Read the entire contents of a file into a bytes vector
/// ///

View File

@ -2,9 +2,11 @@
use std::fmt; use std::fmt;
use anyhow::*; use anyhow::{bail, Error};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use proxmox_io::vec;
pub mod common_regex; pub mod common_regex;
pub mod email; pub mod email;
pub mod fd; pub mod fd;

View File

@ -29,7 +29,7 @@ pub mod epoch_as_rfc3339 {
S: Serializer, S: Serializer,
{ {
use serde::ser::Error; 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()))?; .map_err(|err| Error::custom(err.to_string()))?;
serializer.serialize_str(&s) serializer.serialize_str(&s)
@ -41,7 +41,7 @@ pub mod epoch_as_rfc3339 {
{ {
use serde::de::Error; use serde::de::Error;
String::deserialize(deserializer).and_then(|string| { 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()))
}) })
} }
} }