diff --git a/Cargo.toml b/Cargo.toml index a2f94ab6..84f0c289 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "proxmox-lang", "proxmox-router", "proxmox-schema", + "proxmox-serde", "proxmox-shared-memory", "proxmox-section-config", "proxmox-sortable-macro", diff --git a/Makefile b/Makefile index bdf901c0..dfa5e5de 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ CRATES = \ proxmox-lang \ proxmox-router \ proxmox-schema \ + proxmox-serde \ proxmox-shared-memory \ proxmox-section-config \ proxmox-sortable-macro \ diff --git a/proxmox-serde/Cargo.toml b/proxmox-serde/Cargo.toml new file mode 100644 index 00000000..38275a52 --- /dev/null +++ b/proxmox-serde/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "proxmox-serde" +version = "0.1.0" +authors = ["Proxmox Support Team "] +edition = "2018" +license = "AGPL-3" +description = "Serde formatting tools" + +exclude = [ "debian" ] + +[dependencies] +anyhow = "1.0" +base64 = "0.13" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" + +proxmox-time = { path = "../proxmox-time", version = "1.0.0" } diff --git a/proxmox-serde/debian/changelog b/proxmox-serde/debian/changelog new file mode 100644 index 00000000..85f43b6b --- /dev/null +++ b/proxmox-serde/debian/changelog @@ -0,0 +1,8 @@ +rust-proxmox-serde (0.1.0) stable; urgency=medium + + * imported code from proxmox/src/tools/serde.rs + + * initial release + + -- Proxmox Support Team Wed, 24 Nov 2021 07:42:44 +0100 + diff --git a/proxmox-serde/debian/copyright b/proxmox-serde/debian/copyright new file mode 100644 index 00000000..5661ef60 --- /dev/null +++ b/proxmox-serde/debian/copyright @@ -0,0 +1,16 @@ +Copyright (C) 2021 Proxmox Server Solutions GmbH + +This software is written by Proxmox Server Solutions GmbH + +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 . diff --git a/proxmox-serde/debian/debcargo.toml b/proxmox-serde/debian/debcargo.toml new file mode 100644 index 00000000..1e7ee9f1 --- /dev/null +++ b/proxmox-serde/debian/debcargo.toml @@ -0,0 +1,10 @@ +overlay = "." +crate_src_path = ".." +maintainer = "Proxmox Support Team " + +[source] +vcs_git = "git://git.proxmox.com/git/proxmox.git" +vcs_browser = "https://git.proxmox.com/?p=proxmox.git" + +[packages.lib] +depends = [ "uuid-dev" ] diff --git a/proxmox/src/tools/serde.rs b/proxmox-serde/src/lib.rs similarity index 95% rename from proxmox/src/tools/serde.rs rename to proxmox-serde/src/lib.rs index 6da63f61..83731daf 100644 --- a/proxmox/src/tools/serde.rs +++ b/proxmox-serde/src/lib.rs @@ -1,17 +1,18 @@ //! Serialization helpers for serde +#[macro_use] +pub mod serde_macros; + /// Serialize Unix epoch (i64) as RFC3339. /// /// Usage example: /// ``` -/// # use proxmox::tools; -/// /// use serde::{Deserialize, Serialize}; /// /// # #[derive(Debug)] /// #[derive(Deserialize, PartialEq, Serialize)] /// struct Foo { -/// #[serde(with = "proxmox::tools::serde::epoch_as_rfc3339")] +/// #[serde(with = "proxmox_serde::epoch_as_rfc3339")] /// date: i64, /// } /// @@ -55,7 +56,7 @@ pub mod epoch_as_rfc3339 { /// # #[derive(Debug)] /// #[derive(Deserialize, PartialEq, Serialize)] /// struct Foo { -/// #[serde(with = "proxmox::tools::serde::bytes_as_base64")] +/// #[serde(with = "proxmox_serde::bytes_as_base64")] /// data: Vec, /// } /// @@ -97,7 +98,7 @@ pub mod bytes_as_base64 { /// # #[derive(Debug)] /// #[derive(Deserialize, PartialEq, Serialize)] /// struct Foo { -/// #[serde(with = "proxmox::tools::serde::string_as_base64")] +/// #[serde(with = "proxmox_serde::string_as_base64")] /// data: String, /// } /// @@ -184,7 +185,7 @@ pub mod string_as_base64 { /// # #[derive(Debug)] /// #[derive(Deserialize, PartialEq, Serialize)] /// struct Foo { -/// #[serde(with = "proxmox::tools::serde::bytes_as_base64url_nopad")] +/// #[serde(with = "proxmox_serde::bytes_as_base64url_nopad")] /// data: Vec, /// } /// @@ -230,7 +231,7 @@ pub mod bytes_as_base64url_nopad { /// # #[derive(Debug)] /// #[derive(Deserialize, PartialEq, Serialize)] /// struct Foo { -/// #[serde(with = "proxmox::tools::serde::string_as_base64url_nopad")] +/// #[serde(with = "proxmox_serde::string_as_base64url_nopad")] /// data: String, /// } /// diff --git a/proxmox/src/serde_macros.rs b/proxmox-serde/src/serde_macros.rs similarity index 95% rename from proxmox/src/serde_macros.rs rename to proxmox-serde/src/serde_macros.rs index bcf763a8..9c497ece 100644 --- a/proxmox/src/serde_macros.rs +++ b/proxmox-serde/src/serde_macros.rs @@ -5,7 +5,7 @@ /// ``` /// # use std::str::FromStr; /// # use anyhow::bail; -/// # use proxmox::forward_deserialize_to_from_str; +/// # use proxmox_serde::forward_deserialize_to_from_str; /// struct AsciiAlnum(String); /// /// impl FromStr for AsciiAlnum { @@ -56,7 +56,7 @@ macro_rules! forward_deserialize_to_from_str { /// /// ``` /// # use std::fmt; -/// # use proxmox::forward_serialize_to_display; +/// # use proxmox_serde::forward_serialize_to_display; /// struct DoubleAngleBracketed(String); /// /// impl fmt::Display for DoubleAngleBracketed { diff --git a/proxmox/Cargo.toml b/proxmox/Cargo.toml index 8a5903c0..968a6cd6 100644 --- a/proxmox/Cargo.toml +++ b/proxmox/Cargo.toml @@ -15,19 +15,8 @@ exclude = [ "debian" ] # General dependencies anyhow = "1.0" lazy_static = "1.4" -libc = "0.2" -nix = "0.19.1" -unicode-width ="0.1.8" # tools module: -base64 = "0.13" -endian_trait = { version = "0.6", features = ["arrays"] } regex = "1.2" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" - 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" } diff --git a/proxmox/src/lib.rs b/proxmox/src/lib.rs index 414e7aa9..1ee985e2 100644 --- a/proxmox/src/lib.rs +++ b/proxmox/src/lib.rs @@ -1,9 +1,6 @@ //! Proxmox "tools" package containing some generic tools along with the schema, API and CLI //! helpers. -#[macro_use] -pub mod serde_macros; - pub mod tools; /// An identity (nop) macro. Used by the `#[sortable]` proc macro. diff --git a/proxmox/src/tools/mod.rs b/proxmox/src/tools/mod.rs index ca19273f..51ec5e0a 100644 --- a/proxmox/src/tools/mod.rs +++ b/proxmox/src/tools/mod.rs @@ -7,7 +7,6 @@ use anyhow::{bail, Error}; use proxmox_io::vec; pub mod common_regex; -pub mod serde; const HEX_CHARS: &[u8; 16] = b"0123456789abcdef";