From: Dietmar Maurer <dietmar@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>,
Wolfgang Bumiller <w.bumiller@proxmox.com>
Subject: [pbs-devel] applied: [RFC backup 2/2] use api_string_type macro
Date: Wed, 5 May 2021 08:33:50 +0200 [thread overview]
Message-ID: <6da24a2c-16b3-ba9c-7822-3f59ca837cf7@proxmox.com> (raw)
In-Reply-To: <20210504101930.3590-2-w.bumiller@proxmox.com>
applied, with minor modifications
On 5/4/21 12:19 PM, Wolfgang Bumiller wrote:
> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
> ---
> 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<Self, Error> {
> - 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<str> 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);
> }
next prev parent reply other threads:[~2021-05-05 6:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 10:19 [pbs-devel] [RFC backup 1/2] implement an api_string_type helper macro Wolfgang Bumiller
2021-05-04 10:19 ` [pbs-devel] [RFC backup 2/2] use api_string_type macro Wolfgang Bumiller
2021-05-05 6:33 ` Dietmar Maurer [this message]
2021-05-04 11:17 ` [pbs-devel] [RFC backup 1/2] implement an api_string_type helper macro Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6da24a2c-16b3-ba9c-7822-3f59ca837cf7@proxmox.com \
--to=dietmar@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=w.bumiller@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox