tokio = { version = "1.0", features = ["fs", "net", "rt", "rt-multi-thread", "sync"] }
walkdir = "2"
-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" }
+proxmox-lang = { path = "../proxmox-lang", version = "1" }
[dev-dependencies]
tokio = { version = "1.6", features = [ "macros" ] }
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use proxmox_io::ByteBuffer;
-use proxmox_sys::io_format_err;
+use proxmox_lang::io_format_err;
const BUFFER_SIZE: usize = 8192;
use tokio::sync::mpsc::Sender;
use proxmox_io::ByteBuffer;
-use proxmox_sys::error::io_err_other;
-use proxmox_sys::io_format_err;
+use proxmox_lang::{error::io_err_other, io_format_err};
/// Wrapper around tokio::sync::mpsc::Sender, which implements Write
pub struct AsyncChannelWriter {
proxmox-sys = { path = "../proxmox-sys", optional = true, version = "0.2.0" }
proxmox-io = { path = "../proxmox-io", optional = true, version = "1.0.0" }
+proxmox-lang = { path = "../proxmox-lang", optional = true, version = "1.0.0" }
[features]
default = []
"openssl",
"proxmox-sys",
"proxmox-io/tokio",
+ "proxmox-lang",
"tokio/io-util",
"tokio/sync",
]
use futures::ready;
use proxmox_io::ByteBuffer;
-use proxmox_sys::error::io_err_other;
+use proxmox_lang::error::io_err_other;
// see RFC6455 section 7.4.1
#[derive(Debug, Clone, Copy)]
--- /dev/null
+//! A set of macros/helpers for I/O handling. These provide for `std::io::Error` what `anyhow` provides
+//! for `anyhow::Error.`
+
+use std::io;
+
+/// Helper to convert non-system-errors into an `io::Error` or `io::ErrorKind::Other`.
+///
+/// A more convenient way is to use the `io_format_err!` macro.
+pub fn io_err_other<E: ToString>(e: E) -> io::Error {
+ io::Error::new(std::io::ErrorKind::Other, e.to_string())
+}
+
+
+/// Like anyhow's `format_err` but producing a `std::io::Error`.
+#[macro_export]
+macro_rules! io_format_err {
+ ($($msg:tt)+) => {
+ ::std::io::Error::new(::std::io::ErrorKind::Other, format!($($msg)+))
+ };
+}
+
+/// Shortcut to return an `io::Error::last_os_error`.
+///
+/// This is effectively `return Err(::std::io::Error::last_os_error().into());`.
+#[macro_export]
+macro_rules! io_bail_last {
+ () => {{
+ return Err(::std::io::Error::last_os_error().into());
+ }};
+}
+
+/// Like anyhow's `bail` but producing a `std::io::Error`.
+#[macro_export]
+macro_rules! io_bail {
+ ($($msg:tt)+) => {{
+ return Err($crate::io_format_err!($($msg)+));
+ }};
+}
+
+#[doc(hidden)]
+/// Non-panicking assertion: shortcut for returning an `io::Error` if the condition is not met.
+/// Essentially: `if !expr { io_bail_last!() }`.
+///
+/// Note that this uses `errno`, care must be taken not to overwrite it with different value as a
+/// side effect.
+#[macro_export]
+macro_rules! io_assert {
+ ($value:expr) => {
+ if !$value {
+ $crate::io_bail_last!();
+ }
+ };
+}
mod constnamedbitmap;
+pub mod error;
pub mod ops;
/// Macro to write error-handling blocks (like perl eval {})
use nix::errno::Errno;
use nix::Error;
-/// Helper to convert non-system-errors into an `io::Error` or `io::ErrorKind::Other`.
-///
-/// A more convenient way is to use the `io_format_err!` macro.
-pub fn io_err_other<E: ToString>(e: E) -> io::Error {
- io::Error::new(std::io::ErrorKind::Other, e.to_string())
-}
+use proxmox_lang::error::io_err_other;
/// This trait should be implemented for error types which can represent system errors. Note that
/// it is discouraged to try to map non-system errors to with this trait, since users of this trait
use nix::unistd::Pid;
use nix::NixPath;
-use proxmox_lang::c_str;
+use proxmox_lang::{c_str, error::io_err_other};
-use crate::error::{io_err_other, SysResult};
+use crate::error::SysResult;
use crate::linux::procfs::{MountInfo, PidStat};
use crate::fd::Fd;
use crate::{c_result, c_try};
-//! A set of macros for I/O handling. These provide for `std::io::Error` what `anyhow` provides
-//! for `anyhow::Error.`
-
-/// Like anyhow's `format_err` but producing a `std::io::Error`.
-#[macro_export]
-macro_rules! io_format_err {
- ($($msg:tt)+) => {
- ::std::io::Error::new(::std::io::ErrorKind::Other, format!($($msg)+))
- };
-}
-
-/// Shortcut to return an `io::Error::last_os_error`.
-///
-/// This is effectively `return Err(::std::io::Error::last_os_error().into());`.
-#[macro_export]
-macro_rules! io_bail_last {
- () => {{
- return Err(::std::io::Error::last_os_error().into());
- }};
-}
-
-/// Like anyhow's `bail` but producing a `std::io::Error`.
-#[macro_export]
-macro_rules! io_bail {
- ($($msg:tt)+) => {{
- return Err($crate::io_format_err!($($msg)+));
- }};
-}
-
-#[doc(hidden)]
-/// Non-panicking assertion: shortcut for returning an `io::Error` if the condition is not met.
-/// Essentially: `if !expr { io_bail_last!() }`.
-///
-/// Note that this uses `errno`, care must be taken not to overwrite it with different value as a
-/// side effect.
-#[macro_export]
-macro_rules! io_assert {
- ($value:expr) => {
- if !$value {
- $crate::io_bail_last!();
- }
- };
-}
-
/// Roughly equivalent to `nix::Errno::result`. Turns a `-1` into an `io::Error`, while passing
/// other values through as `Ok(n)`.
#[macro_export]
use nix::sys::mman;
-use crate::error::{io_err_other, SysError};
+use proxmox_lang::error::io_err_other;
+
+use crate::error::{SysError};
pub struct Mmap<T> {
data: *mut T,