From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6C664797D3 for ; Wed, 5 May 2021 08:33:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6239710A4B for ; Wed, 5 May 2021 08:33:52 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 70B2110A3D for ; Wed, 5 May 2021 08:33:51 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3C88A4206C for ; Wed, 5 May 2021 08:33:51 +0200 (CEST) To: Proxmox Backup Server development discussion , Wolfgang Bumiller References: <20210504101930.3590-1-w.bumiller@proxmox.com> <20210504101930.3590-2-w.bumiller@proxmox.com> From: Dietmar Maurer Message-ID: <6da24a2c-16b3-ba9c-7822-3f59ca837cf7@proxmox.com> Date: Wed, 5 May 2021 08:33:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210504101930.3590-2-w.bumiller@proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-SPAM-LEVEL: Spam detection results: 0 AWL 0.257 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [acme.rs] Subject: [pbs-devel] applied: [RFC backup 2/2] use api_string_type macro X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 May 2021 06:33:52 -0000 applied, with minor modifications On 5/4/21 12:19 PM, Wolfgang Bumiller wrote: > Signed-off-by: Wolfgang Bumiller > --- > src/api2/types/acme.rs | 68 ++++-------------------------------------- > 1 file changed, 6 insertions(+), 62 deletions(-) > > diff --git a/src/api2/types/acme.rs b/src/api2/types/acme.rs > index cc5df322..f66a0801 100644 > --- a/src/api2/types/acme.rs > +++ b/src/api2/types/acme.rs > @@ -1,6 +1,3 @@ > -use std::fmt; > - > -use anyhow::Error; > use serde::{Deserialize, Serialize}; > > use proxmox::api::{api, schema::{Schema, StringSchema, ApiStringFormat}}; > @@ -64,63 +61,10 @@ pub struct KnownAcmeDirectory { > pub url: &'static str, > } > > -#[api(format: &PROXMOX_SAFE_ID_FORMAT)] > -/// ACME account name. > -#[derive(Clone, Eq, PartialEq, Hash, Deserialize, Serialize)] > -#[serde(transparent)] > -pub struct AcmeAccountName(String); > - > -impl AcmeAccountName { > - pub fn into_string(self) -> String { > - self.0 > - } > - > - pub fn from_string(name: String) -> Result { > - match &Self::API_SCHEMA { > - Schema::String(s) => s.check_constraints(&name)?, > - _ => unreachable!(), > - } > - Ok(Self(name)) > - } > - > - pub unsafe fn from_string_unchecked(name: String) -> Self { > - Self(name) > - } > -} > - > -impl std::ops::Deref for AcmeAccountName { > - type Target = str; > - > - #[inline] > - fn deref(&self) -> &str { > - &self.0 > - } > -} > - > -impl std::ops::DerefMut for AcmeAccountName { > - #[inline] > - fn deref_mut(&mut self) -> &mut str { > - &mut self.0 > - } > -} > - > -impl AsRef for AcmeAccountName { > - #[inline] > - fn as_ref(&self) -> &str { > - self.0.as_ref() > - } > -} > - > -impl fmt::Debug for AcmeAccountName { > - #[inline] > - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { > - fmt::Debug::fmt(&self.0, f) > - } > -} > - > -impl fmt::Display for AcmeAccountName { > - #[inline] > - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { > - fmt::Display::fmt(&self.0, f) > - } > +api_string_type! { > + #[api(format: &PROXMOX_SAFE_ID_FORMAT)] > + /// ACME account name. > + #[derive(Clone, Eq, PartialEq, Hash, Deserialize, Serialize)] > + #[serde(transparent)] > + pub struct AcmeAccountName(String); > }