proxmox-serde: add new crate with code from proxmox/src/tools/serde.rs
This commit is contained in:
parent
b06807532e
commit
194b028789
@ -9,6 +9,7 @@ members = [
|
||||
"proxmox-lang",
|
||||
"proxmox-router",
|
||||
"proxmox-schema",
|
||||
"proxmox-serde",
|
||||
"proxmox-shared-memory",
|
||||
"proxmox-section-config",
|
||||
"proxmox-sortable-macro",
|
||||
|
1
Makefile
1
Makefile
@ -10,6 +10,7 @@ CRATES = \
|
||||
proxmox-lang \
|
||||
proxmox-router \
|
||||
proxmox-schema \
|
||||
proxmox-serde \
|
||||
proxmox-shared-memory \
|
||||
proxmox-section-config \
|
||||
proxmox-sortable-macro \
|
||||
|
17
proxmox-serde/Cargo.toml
Normal file
17
proxmox-serde/Cargo.toml
Normal file
@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "proxmox-serde"
|
||||
version = "0.1.0"
|
||||
authors = ["Proxmox Support Team <support@proxmox.com>"]
|
||||
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" }
|
8
proxmox-serde/debian/changelog
Normal file
8
proxmox-serde/debian/changelog
Normal file
@ -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 <support@proxmox.com> Wed, 24 Nov 2021 07:42:44 +0100
|
||||
|
16
proxmox-serde/debian/copyright
Normal file
16
proxmox-serde/debian/copyright
Normal file
@ -0,0 +1,16 @@
|
||||
Copyright (C) 2021 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/>.
|
10
proxmox-serde/debian/debcargo.toml
Normal file
10
proxmox-serde/debian/debcargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
overlay = "."
|
||||
crate_src_path = ".."
|
||||
maintainer = "Proxmox Support Team <support@proxmox.com>"
|
||||
|
||||
[source]
|
||||
vcs_git = "git://git.proxmox.com/git/proxmox.git"
|
||||
vcs_browser = "https://git.proxmox.com/?p=proxmox.git"
|
||||
|
||||
[packages.lib]
|
||||
depends = [ "uuid-dev" ]
|
@ -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<u8>,
|
||||
/// }
|
||||
///
|
||||
@ -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<u8>,
|
||||
/// }
|
||||
///
|
||||
@ -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,
|
||||
/// }
|
||||
///
|
@ -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 {
|
@ -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" }
|
||||
|
@ -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.
|
||||
|
@ -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";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user