merge api, sys and tools into proxmox directly

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-01-21 11:56:56 +01:00
parent 93cf522dd8
commit 436bf05e0b
56 changed files with 129 additions and 356 deletions

View File

@ -1,12 +1,8 @@
[workspace]
members = [
"proxmox",
"proxmox-api",
"proxmox-api-macro",
"proxmox-sortable-macro",
"proxmox-sys",
"proxmox-tools",
"proxmox",
]
exclude = [
"build",

View File

@ -1,6 +1,6 @@
# Shortcut for common operations:
CRATES=proxmox proxmox-api proxmox-api-macro proxmox-sortable-macro proxmox-sys proxmox-tools
CRATES=proxmox proxmox-api-macro proxmox-sortable-macro
# By default we just run checks:
.PHONY: all
@ -12,14 +12,8 @@ deb: $(foreach c,$(CRATES), $c-deb)
lintian build/*.deb
.PHONY: dinstall
dinstall:
$(MAKE) proxmox-tools-deb proxmox-sortable-macro-deb
sudo dpkg -i build/librust-*.deb
$(MAKE) proxmox-api-macro-deb proxmox-sys-deb
sudo dpkg -i build/librust-*.deb
$(MAKE) proxmox-deb
sudo dpkg -i build/librust-*.deb
sudo -k
dinstall: deb
sudo -k dpkg -i build/librust-*.deb
%-deb:
./build.sh $*

View File

@ -19,8 +19,7 @@ syn = { version = "1.0", features = [ "full" ] }
[dev-dependencies]
futures = "0.3"
proxmox = { path = "../proxmox" }
proxmox-api = { path = "../proxmox-api", features = [ "test-harness" ] }
proxmox = { path = "../proxmox", features = [ "test-harness" ] }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"

View File

@ -1,35 +0,0 @@
[package]
name = "proxmox-api"
edition = "2018"
version = "0.1.2"
authors = [ "Wolfgang Bumiller <w.bumiller@proxmox.com>" ]
license = "AGPL-3"
description = "Proxmox API library"
exclude = [ "debian" ]
[dependencies]
bytes = "0.5"
failure = "0.1"
futures = "0.3"
http = "0.2"
proxmox-tools = { version = "0.1.1", path = "../proxmox-tools" }
regex = "1.2"
rustyline = "5.0.5"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
textwrap = "0.11"
url = "2.1"
tokio = { version = "0.2", features = [], optional = true }
hyper = { version = "0.13", optional = true }
[dev-dependencies]
lazy_static = "1.4"
[features]
default = [ "router", "cli" ]
router = [ "hyper", "tokio" ]
cli = [ "router", "hyper", "tokio" ]
test-harness = []

View File

@ -1,23 +0,0 @@
rust-proxmox-api (0.1.2-1) unstable; urgency=medium
* improve generate_usage_str()
-- Proxmox Support Team <support@proxmox.com> Wed, 15 Jan 2020 15:21:40 +0100
rust-proxmox-api (0.1.1-1) proxmox-rust; urgency=medium
* switch packaging to debcargo with local crate support
-- Proxmox Support Team <support@proxmox.com> Mon, 13 Jan 2020 10:41:01 +0100
rust-proxmox-api (0.1.1) proxmox-rust; urgency=medium
* bump proxmox-tools dependency
-- Proxmox Support Team <support@proxmox.com> Thu, 02 Jan 2020 14:25:22 +0100
rust-proxmox-api (0.1.0) proxmox-rust; urgency=medium
* Initial packaging.
-- Proxmox Support Team <support@proxmox.com> Tue, 17 Dec 2019 14:47:44 +0100

View File

@ -1,16 +0,0 @@
Copyright (C) 2019 Proxmox Server Solutions GmbH
This software is written by Proxmox Server Solutions GmbH <support@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/>.

View File

@ -1,8 +0,0 @@
overlay = "."
crate_src_path = ".."
[source]
# TODO: update once public
vcs_git = ""
vcs_browser = ""
maintainer = "Proxmox Support Team <support@proxmox.com>"

View File

@ -1,23 +0,0 @@
[package]
name = "proxmox-sys"
edition = "2018"
version = "0.1.3"
authors = [
"Dietmar Maurer <dietmar@proxmox.com>",
"Wolfgang Bumiller <w.bumiller@proxmox.com>",
]
license = "AGPL-3"
description = "Proxmox system library"
exclude = [ "debian" ]
[dependencies]
failure = "0.1"
lazy_static = "1.4"
libc = "0.2"
nix = "0.16"
proxmox-tools = { version = "0.1.2", path = "../proxmox-tools" }
# Docs should be able to reference the proxmox crate.
[dev-dependencies]
proxmox = { path = "../proxmox" }

View File

@ -1,44 +0,0 @@
rust-proxmox-sys (0.1.3-1) proxmox-rust; urgency=medium
* rename PidStat::read_for_pid -> read_from_pid
* sys: drop deprecated items
-- Proxmox Support Team <support@proxmox.com> Thu, 16 Jan 2020 11:34:14 +0100
rust-proxmox-sys (0.1.2-1) proxmox-rust; urgency=medium
* Add helper macros for ffi code: c_try, c_result, io_bail, io_bail_last,
io_format_err, c_str
* Add SysResult and SysError traits which provide convenient methods to
convert nix::Results and nix::Errors to std::io::Result and
std::io::Error.
* Extend /proc/PID/stat parsing by pid, ppid and num_threads
* Rename ProcFsPidStat to PidStat, deprecate standalone functions for it.
* Add /proc/PID/mountinfo parsing (proxmox::sys::procfs::MountInfo)
* Add proxmox::sys::pid::PidFd for pidfd handling
-- Proxmox Support Team <support@proxmox.com> Wed, 15 Jan 2020 15:31:05 +0100
rust-proxmox-sys (0.1.1-1) proxmox-rust; urgency=medium
* switch packaging to debcargo with local crate support
-- Proxmox Support Team <support@proxmox.com> Mon, 13 Jan 2020 10:41:01 +0100
rust-proxmox-sys (0.1.1) proxmox-rust; urgency=medium
* added: various helpers for dealing with nix and io errors
-- Proxmox Support Team <support@proxmox.com> Thu, 02 Jan 2020 14:32:44 +0100
rust-proxmox-sys (0.1.0) proxmox-rust; urgency=medium
* Initial packaging.
-- Proxmox Support Team <support@proxmox.com> Tue, 17 Dec 2019 14:47:44 +0100

View File

@ -1,16 +0,0 @@
Copyright (C) 2019 Proxmox Server Solutions GmbH
This software is written by Proxmox Server Solutions GmbH <support@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/>.

View File

@ -1,8 +0,0 @@
overlay = "."
crate_src_path = ".."
[source]
# TODO: update once public
vcs_git = ""
vcs_browser = ""
maintainer = "Proxmox Support Team <support@proxmox.com>"

View File

@ -1,33 +0,0 @@
[package]
name = "proxmox-tools"
edition = "2018"
version = "0.1.2"
authors = [
"Dietmar Maurer <dietmar@proxmox.com>",
"Wolfgang Bumiller <w.bumiller@proxmox.com>",
]
license = "AGPL-3"
description = "Proxmox tools"
exclude = [ "debian" ]
[dependencies]
base64 = "0.10"
chrono = "0.4"
endian_trait = { version = "0.6", features = ["arrays"] }
failure = "0.1"
lazy_static = "1.4"
libc = "0.2"
nix = "0.16"
regex = "1.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
valgrind_request = { git = "https://github.com/edef1c/libvalgrind_request", version = "1.1.0", optional = true }
[features]
default = []
valgrind = [ "valgrind_request" ]
# Docs should be able to reference the proxmox crate.
[dev-dependencies]
proxmox = { path = "../proxmox" }

View File

@ -1,21 +0,0 @@
rust-proxmox-tools (0.1.2-1) unstable; urgency=medium
* take a reference to the dirfd in Fd::openat
* remove accidentally commited debian/files
* switch packaging to debcargo with local crate support
-- Proxmox Support Team <support@proxmox.com> Mon, 13 Jan 2020 10:41:01 +0100
rust-proxmox-tools (0.1.1) proxmox-rust; urgency=medium
* correctly default to mode 0644 in replace_file
-- Proxmox Support Team <support@proxmox.com> Thu, 02 Jan 2020 14:38:22 +0100
rust-proxmox-tools (0.1.0) proxmox-rust; urgency=medium
* Initial packaging.
-- Proxmox Support Team <support@proxmox.com> Tue, 17 Dec 2019 13:50:53 +0100

View File

@ -1,16 +0,0 @@
Copyright (C) 2019 Proxmox Server Solutions GmbH
This software is written by Proxmox Server Solutions GmbH <support@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/>.

View File

@ -1,8 +0,0 @@
overlay = "."
crate_src_path = ".."
[source]
# TODO: update once public
vcs_git = ""
vcs_browser = ""
maintainer = "Proxmox Support Team <support@proxmox.com>"

View File

@ -1,7 +1,7 @@
[package]
name = "proxmox"
edition = "2018"
version = "0.1.4"
version = "0.1.5"
authors = [
"Dietmar Maurer <dietmar@proxmox.com>",
"Wolfgang Bumiller <w.bumiller@proxmox.com>",
@ -12,16 +12,50 @@ description = "Proxmox library"
exclude = [ "debian" ]
[dependencies]
proxmox-api = { path = "../proxmox-api", default-features = false, version = "0.1.2" }
# General dependencies
failure = "0.1"
lazy_static = "1.4"
libc = "0.2"
nix = "0.16"
# tools module:
base64 = "0.10"
chrono = "0.4"
endian_trait = { version = "0.6", features = ["arrays"] }
regex = "1.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
valgrind_request = { git = "https://github.com/edef1c/libvalgrind_request", version = "1.1.0", optional = true }
# libc, nix, lazy_static
# sys module:
# libc, nix, lazy_static
# api module:
bytes = "0.5"
futures = "0.3"
http = "0.2"
hyper = { version = "0.13", optional = true }
rustyline = "5.0.5"
serde_derive = "1.0"
textwrap = "0.11"
tokio = { version = "0.2", features = [], optional = true }
url = "2.1"
#regex, serde, serde_json
# Macro crates:
proxmox-api-macro = { path = "../proxmox-api-macro", optional = true, version = "0.1.1" }
proxmox-sys = { path = "../proxmox-sys", version = "0.1.3" }
proxmox-tools = { path = "../proxmox-tools", version = "0.1.2" }
proxmox-sortable-macro = { path = "../proxmox-sortable-macro", optional = true, version = "0.1.0" }
[features]
api-macro = ["proxmox-api-macro"]
cli = ["proxmox-api/cli"]
default = [ "router", "cli" ]
router = ["proxmox-api/router"]
sortable-macro = ["proxmox-sortable-macro"]
valgrind = ["proxmox-tools/valgrind"]
# api:
api-macro = ["proxmox-api-macro"]
test-harness = []
cli = [ "router", "hyper", "tokio" ]
router = [ "hyper", "tokio" ]
# tools:
#valgrind = ["proxmox-tools/valgrind"]

View File

@ -1,3 +1,10 @@
rust-proxmox (0.1.5-1) unstable; urgency=medium
* merge tools, sys and api crate into the proxmox main crate to reduce
the dependency management burden
-- Proxmox Support Team <support@proxmox.com> Tue, 21 Jan 2020 12:13:18 +0100
rust-proxmox (0.1.4-1) unstable; urgency=medium
* sys: rename PidStat::read_for_pid -> read_from_pid

View File

@ -1,4 +1,4 @@
Copyright (C) 2019 Proxmox Server Solutions GmbH
Copyright (C) 2019,2020 Proxmox Server Solutions GmbH
This software is written by Proxmox Server Solutions GmbH <support@proxmox.com>

View File

@ -35,7 +35,7 @@ pub use readline::*;
use std::collections::HashMap;
use crate::ApiMethod;
use crate::api::ApiMethod;
/// Completion function for single parameters.
///

View File

@ -3,9 +3,9 @@ use serde_json::Value;
use std::cell::RefCell;
use std::sync::Arc;
use crate::format::*;
use crate::schema::*;
use crate::*;
use crate::api::format::*;
use crate::api::schema::*;
use crate::api::*;
use super::environment::CliEnvironment;

View File

@ -1,6 +1,6 @@
use super::*;
use crate::schema::*;
use crate::api::schema::*;
fn record_done_argument(
done: &mut HashMap<String, String>,
@ -295,7 +295,7 @@ mod test {
use failure::*;
use serde_json::Value;
use crate::{cli::*, schema::*, *};
use crate::api::{cli::*, schema::*, *};
fn dummy_method(
_param: Value,

View File

@ -1,7 +1,7 @@
use serde_json::Value;
use std::collections::HashMap;
use crate::{RpcEnvironment, RpcEnvironmentType};
use crate::api::{RpcEnvironment, RpcEnvironmentType};
/// `RpcEnvironmet` implementation for command line tools
#[derive(Default)]

View File

@ -4,8 +4,8 @@ use serde_json::Value;
use std::collections::HashSet;
use crate::format::*;
use crate::schema::*;
use crate::api::format::*;
use crate::api::schema::*;
use super::{CliCommand, CliCommandMap, CommandLineInterface};

View File

@ -1,7 +1,7 @@
use failure::*;
use serde_json::Value;
use crate::schema::*;
use crate::api::schema::*;
#[derive(Debug)]
enum RawArgument {

View File

@ -30,7 +30,7 @@ impl std::ops::Deref for ConstRegexPattern {
/// Macro to generate a ConstRegexPattern
///
/// ```
/// # use proxmox_api::*;
/// # use proxmox::const_regex;
/// #
/// const_regex!{
/// FILE_EXTENSION_REGEX = r".*\.([a-zA-Z]+)$";
@ -53,8 +53,8 @@ macro_rules! const_regex {
($($pub:tt)*) $(#[$attr:meta])* $name:ident = $regex:expr;
$($rest:tt)*
) => {
$(#[$attr])* $($pub)* const $name: $crate::const_regex::ConstRegexPattern =
$crate::const_regex::ConstRegexPattern {
$(#[$attr])* $($pub)* const $name: $crate::api::const_regex::ConstRegexPattern =
$crate::api::const_regex::ConstRegexPattern {
regex_string: $regex,
regex_obj: (|| -> &'static ::regex::Regex {
::lazy_static::lazy_static! {

View File

@ -28,8 +28,8 @@ impl fmt::Display for HttpError {
#[macro_export]
macro_rules! http_err {
($status:ident, $msg:expr) => {{
::failure::Error::from($crate::error::HttpError::new(
$crate::error::StatusCode::$status,
::failure::Error::from($crate::api::error::HttpError::new(
$crate::api::error::StatusCode::$status,
$msg,
))
}};

View File

@ -4,8 +4,8 @@ use failure::Error;
use std::io::Write;
use crate::schema::*;
use crate::{ApiHandler, ApiMethod};
use crate::api::schema::*;
use crate::api::{ApiHandler, ApiMethod};
/// Enumerate different styles to display parameters/properties.
#[derive(Copy, Clone)]
@ -265,11 +265,11 @@ fn dump_method_definition(method: &str, path: &str, def: Option<&ApiMethod>) ->
/// Generate ReST Documentaion for a complete API defined by a ``Router``.
pub fn dump_api(
output: &mut dyn Write,
router: &crate::Router,
router: &crate::api::Router,
path: &str,
mut pos: usize,
) -> Result<(), Error> {
use crate::SubRoute;
use crate::api::SubRoute;
let mut cond_print = |x| -> Result<_, Error> {
if let Some(text) = x {

View File

@ -1,5 +1,8 @@
//! Proxmox API module. This provides utilities for HTTP and command line APIs.
#[cfg(feature = "api-macro")]
pub use proxmox_api_macro::{api, router};
#[doc(hidden)]
pub mod const_regex;
#[doc(hidden)]
@ -35,3 +38,6 @@ pub use router::{
#[cfg(feature = "cli")]
pub mod cli;
#[cfg(feature = "api-macro")]
pub use proxmox_api_macro::{api, router};

View File

@ -9,8 +9,8 @@ use http::{Method, Response};
use hyper::Body;
use serde_json::Value;
use crate::schema::{self, ObjectSchema, Schema};
use crate::RpcEnvironment;
use crate::api::schema::{self, ObjectSchema, Schema};
use crate::api::RpcEnvironment;
/// A synchronous API handler gets a json Value as input and returns a json Value as output.
///
@ -18,7 +18,7 @@ use crate::RpcEnvironment;
/// ```
/// # use failure::*;
/// # use serde_json::{json, Value};
/// # use proxmox_api::{*, schema::*};
/// # use proxmox::api::{*, schema::*};
/// #
/// fn hello(
/// param: Value,
@ -44,7 +44,7 @@ pub type ApiHandlerFn = &'static (dyn Fn(Value, &ApiMethod, &mut dyn RpcEnvironm
/// ```
/// # use failure::*;
/// # use serde_json::{json, Value};
/// # use proxmox_api::{*, schema::*};
/// # use proxmox::api::{*, schema::*};
/// #
/// use futures::*;
///
@ -77,7 +77,7 @@ pub type ApiFuture<'a> = Pin<Box<dyn Future<Output = Result<Value, failure::Erro
/// ```
/// # use failure::*;
/// # use serde_json::{json, Value};
/// # use proxmox_api::{*, schema::*};
/// # use proxmox::api::{*, schema::*};
/// #
/// use futures::*;
/// use hyper::{Body, Response, http::request::Parts};
@ -184,15 +184,16 @@ pub enum SubRoute {
#[macro_export]
macro_rules! list_subdirs_api_method {
($map:expr) => {
$crate::ApiMethod::new(
&$crate::ApiHandler::Sync( & |_, _, _| {
$crate::api::ApiMethod::new(
&$crate::api::ApiHandler::Sync( & |_, _, _| {
let index = ::serde_json::json!(
$map.iter().map(|s| ::serde_json::json!({ "subdir": s.0}))
.collect::<Vec<::serde_json::Value>>()
);
Ok(index)
}),
&$crate::schema::ObjectSchema::new("Directory index.", &[]).additional_properties(true)
&$crate::api::schema::ObjectSchema::new("Directory index.", &[])
.additional_properties(true)
)
}
}
@ -213,7 +214,7 @@ macro_rules! list_subdirs_api_method {
///```
/// # use failure::*;
/// # use serde_json::{json, Value};
/// # use proxmox_api::{*, schema::*};
/// # use proxmox::api::{*, schema::*};
/// #
/// const API_METHOD_HELLO: ApiMethod = ApiMethod::new(
/// &ApiHandler::Sync(&|_, _, _| {

View File

@ -1,4 +1,4 @@
use proxmox_tools::AsAny;
use crate::tools::AsAny;
use serde_json::Value;

View File

@ -10,7 +10,7 @@ use failure::*;
use serde_json::{json, Value};
use url::form_urlencoded;
use crate::const_regex::ConstRegexPattern;
use crate::api::const_regex::ConstRegexPattern;
/// Error type for schema validation
///
@ -466,7 +466,7 @@ impl ObjectSchema {
/// `schema()` method to convert them into a `Schema`.
///
/// ```
/// # use proxmox_api::{*, schema::*};
/// # use proxmox::api::{*, schema::*};
/// #
/// const SIMPLE_OBJECT: Schema = ObjectSchema::new(
/// "A very simple object with 2 properties",
@ -511,7 +511,7 @@ pub enum Schema {
/// Simple list all possible values.
///
/// ```
/// # use proxmox_api::{*, schema::*};
/// # use proxmox::api::{*, schema::*};
/// const format: ApiStringFormat = ApiStringFormat::Enum(&["vm", "ct"]);
/// ```
///
@ -520,7 +520,8 @@ pub enum Schema {
/// Use a regular expression to describe valid strings.
///
/// ```
/// # use proxmox_api::{*, schema::*};
/// # use proxmox::api::{*, schema::*};
/// # use proxmox::const_regex;
/// const_regex! {
/// pub SHA256_HEX_REGEX = r"^[a-f0-9]{64}$";
/// }
@ -541,7 +542,7 @@ pub enum Schema {
/// of simple data types, and objects with simple properties.
///
/// ```
/// # use proxmox_api::{*, schema::*};
/// # use proxmox::api::{*, schema::*};
/// #
/// const PRODUCT_LIST_SCHEMA: Schema =
/// ArraySchema::new("Product List.", &IntegerSchema::new("Product ID").schema())

View File

@ -1,19 +1,16 @@
pub use proxmox_sys as sys;
pub use proxmox_tools as tools;
//! Proxmox "tools" package containing some generic tools along with the schema, API and CLI
//! helpers.
// Both `proxmox_api` and the 2 macros from `proxmox_api_macro` should be
// exposed via `proxmox::api`.
pub mod api {
pub use proxmox_api::*;
#[cfg(feature = "api-macro")]
pub use proxmox_api_macro::{api, router};
pub mod api;
pub mod sys;
pub mod tools;
/// An identity (nop) macro. Used by the `#[sortable]` proc macro.
#[cfg(feature = "sortable-macro")]
#[macro_export]
macro_rules! identity {
($($any:tt)*) => ($($any)*)
}
#[cfg(feature = "sortable-macro")]
pub use proxmox_tools::identity;
#[cfg(feature = "sortable-macro")]
pub use proxmox_sortable_macro as sortable_macro;
#[cfg(feature = "sortable-macro")]
pub use proxmox_sortable_macro::sortable;

View File

@ -36,7 +36,7 @@ pub fn io_err_other<E: ToString>(e: E) -> io::Error {
/// # use failure::{bail, Error};
/// use nix::{dir::Dir, fcntl::OFlag, sys::stat::Mode};
///
/// use proxmox_sys::error::SysError;
/// use proxmox::sys::error::SysError;
///
/// # fn test() -> Result<(), Error> {
///
@ -116,7 +116,7 @@ impl SysError for nix::Error {
/// # use std::os::unix::io::RawFd;
/// # use failure::{bail, Error};
///
/// use proxmox_sys::error::SysResult;
/// use proxmox::sys::error::SysResult;
///
/// struct MyReader(RawFd);
///
@ -150,7 +150,7 @@ macro_rules! other_error {
#[inline]
fn into_io_result(self) -> io::Result<T> {
self.map_err($crate::error::io_err_other)
self.map_err($crate::sys::error::io_err_other)
}
}
};

View File

@ -1,7 +1,6 @@
//! Linux specific helpers and syscall wrapper
use failure::*;
use proxmox_tools as tools;
pub mod magic;
pub mod pid;
@ -9,7 +8,7 @@ pub mod procfs;
/// Get pseudo random data (/dev/urandom)
pub fn random_data(size: usize) -> Result<Vec<u8>, Error> {
let mut buffer = tools::vec::undefined(size);
let mut buffer = crate::tools::vec::undefined(size);
fill_with_random_data(&mut buffer)?;
Ok(buffer)

View File

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

View File

@ -12,8 +12,8 @@ use lazy_static::lazy_static;
use libc;
use nix::unistd::Pid;
use proxmox_tools::fs::file_read_firstline;
use proxmox_tools::parse::hex_nibble;
use crate::tools::fs::file_read_firstline;
use crate::tools::parse::hex_nibble;
pub mod mountinfo;
#[doc(inline)]

View File

@ -13,7 +13,7 @@ use nix::sys::stat;
use nix::unistd::{self, Gid, Uid};
use serde_json::Value;
use crate::fd::Fd;
use crate::tools::fd::Fd;
use crate::try_block;
/// Read the entire contents of a file into a bytes vector
@ -241,7 +241,7 @@ pub fn create_dir<P: AsRef<Path>>(path: P, options: CreateOptions) -> Result<(),
/// ```no_run
/// # use nix::sys::stat::Mode;
/// # use nix::unistd::{Gid, Uid};
/// # use proxmox_tools::fs::{create_path, CreateOptions};
/// # use proxmox::tools::fs::{create_path, CreateOptions};
/// # fn code() -> Result<(), failure::Error> {
/// create_path(
/// "/var/lib/mytool/wwwdata",

View File

@ -5,7 +5,7 @@ use std::mem;
use endian_trait::Endian;
use crate::vec::{self, ByteVecExt};
use crate::tools::vec::{self, ByteVecExt};
/// Adds some additional related functionality for types implementing [`Read`](std::io::Read).
///

View File

@ -20,12 +20,6 @@ pub use uuid::Uuid;
#[doc(inline)]
pub use as_any::AsAny;
/// An identity (nop) macro. Used by the `#[sortable]` proc macro.
#[macro_export]
macro_rules! identity {
($($any:tt)*) => ($($any)*)
}
/// Evaluates to the offset (in bytes) of a given member within a struct
#[macro_export]
macro_rules! offsetof {
@ -38,7 +32,7 @@ macro_rules! offsetof {
///
/// This should compile:
/// ```
/// # use proxmox_tools::static_assert_size;
/// # use proxmox::static_assert_size;
/// #[repr(C)]
/// struct Stuff {
/// value: [u8; 32]
@ -48,7 +42,7 @@ macro_rules! offsetof {
///
/// This should fail to compile:
/// ```compile_fail
/// # use proxmox_tools::static_assert_size;
/// # use proxmox::static_assert_size;
/// #[repr(C)]
/// struct Stuff {
/// value: [u8; 32]
@ -68,7 +62,7 @@ macro_rules! static_assert_size {
///
/// #### Example:
/// ```
/// # use proxmox_tools::try_block;
/// # use proxmox::try_block;
/// # use failure::*;
/// # let some_condition = false;
/// let result = try_block!({
@ -94,7 +88,7 @@ pub fn digest_to_hex(digest: &[u8]) -> String {
/// Convert a byte slice to a string of hexadecimal digits.
///
/// ```
/// # use proxmox_tools::bin_to_hex;
/// # use proxmox::tools::bin_to_hex;
///
/// let text = bin_to_hex(&[1, 2, 0xff]);
/// assert_eq!(text, "0102ff");
@ -116,7 +110,7 @@ pub fn bin_to_hex(digest: &[u8]) -> String {
/// digits.
///
/// ```
/// # use proxmox_tools::hex_to_bin;
/// # use proxmox::tools::hex_to_bin;
///
/// let data = hex_to_bin("aabb0123").unwrap();
/// assert_eq!(&data, &[0xaa, 0xbb, 0x01, 0x23]);

View File

@ -4,8 +4,7 @@
///
/// Usage example:
/// ```
/// # pub extern crate proxmox_tools;
/// # mod proxmox { pub use proxmox_tools as tools; }
/// # use proxmox::tools;
///
/// use chrono::{DateTime, TimeZone, Utc};
/// use serde::{Deserialize, Serialize};
@ -57,9 +56,6 @@ pub mod date_time_as_rfc3339 {
///
/// Usage example:
/// ```
/// # pub extern crate proxmox_tools;
/// # mod proxmox { pub use proxmox_tools as tools; }
///
/// use serde::{Deserialize, Serialize};
///
/// # #[derive(Debug)]

View File

@ -5,7 +5,7 @@ use std::fmt;
use failure::{bail, Error};
use crate::parse::hex_nibble;
use crate::tools::parse::hex_nibble;
#[link(name = "uuid")]
extern "C" {
@ -17,7 +17,7 @@ extern "C" {
/// Uuid generated with the system's native libuuid.
///
/// ```
/// use proxmox_tools::uuid::Uuid;
/// use proxmox::tools::uuid::Uuid;
///
/// let uuid = Uuid::generate();
/// println!("Generated uuid: {}", uuid);
@ -57,7 +57,7 @@ impl Uuid {
/// Parse a uuid in optionally-hyphenated format.
///
/// ```
/// use proxmox_tools::uuid::Uuid;
/// use proxmox::tools::uuid::Uuid;
///
/// let gen = Uuid::generate();
/// let text = format!("{}", gen);

View File

@ -13,7 +13,7 @@
//!
//! This module provides some helpers for this kind of code. Many of these are supposed to stay on
//! a lower level, with I/O helpers for types implementing [`Read`](std::io::Read) being available
//! in the [`tools::io`](crate::io) module.
//! in the [`tools::io`](crate::tools::io) module.
//!
//! Examples:
//! ```no_run