From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <t.lamprecht@proxmox.com>
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 EEC3480DE4
 for <pbs-devel@lists.proxmox.com>; Sat, 20 Nov 2021 22:55:22 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id DF4C7F9CA
 for <pbs-devel@lists.proxmox.com>; Sat, 20 Nov 2021 22:55:22 +0100 (CET)
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 43916F9BC
 for <pbs-devel@lists.proxmox.com>; Sat, 20 Nov 2021 22:55:22 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1304C43CBE
 for <pbs-devel@lists.proxmox.com>; Sat, 20 Nov 2021 22:55:22 +0100 (CET)
Message-ID: <1fdb071e-31b1-6f64-0384-31cf93197781@proxmox.com>
Date: Sat, 20 Nov 2021 22:55:21 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101
 Thunderbird/95.0
Content-Language: en-US
To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>, Dietmar Maurer <dietmar@proxmox.com>
References: <20211118072922.2233682-1-dietmar@proxmox.com>
 <20211118072922.2233682-2-dietmar@proxmox.com>
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
In-Reply-To: <20211118072922.2233682-2-dietmar@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.109 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 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. [format.rs, proxmox-tape.rs, datastore.rs, lib.rs]
Subject: Re: [pbs-devel] [RFC proxmox-backup v3 1/2] pbs-api-types: more
 flexible HumanByte type
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Sat, 20 Nov 2021 21:55:23 -0000

On 18.11.21 08:29, Dietmar Maurer wrote:
> This implements a parser for human readabkle byte sizes.
> 
> Examples: "1KB", "1.5 Mib", "3T"
> 
> Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
> ---
>  pbs-api-types/src/human_byte.rs   | 353 ++++++++++++++++++++++++++++++
>  pbs-api-types/src/lib.rs          |   3 +
>  pbs-client/src/backup_writer.rs   |  19 +-
>  pbs-datastore/src/datastore.rs    |  13 +-
>  pbs-tools/Cargo.toml              |   1 +
>  pbs-tools/src/format.rs           |  55 +----
>  src/bin/proxmox-tape.rs           |   7 +-
>  src/server/email_notifications.rs |   5 +-
>  8 files changed, 382 insertions(+), 74 deletions(-)
>  create mode 100644 pbs-api-types/src/human_byte.rs
> 
>

I replaced this commit by four separate ones:

42ba4cd3 human byte: make proper proxmox API type
ab1c07a6 human byte: add from string parser
930a7146 human byte: add proper unit type and support base-10
a58a5cf7 move HumanByte to pbs-abi-types crate

I based it quite a bit on the semantics of yours. But made a few changes, the
two commits in the middle contain a bit more info in the commit message.

Also incorporated a bit of your code 1:1 and all of your (adapted) tests, plus
added a few more.

IMO the result is OK'ish and definitively better than my lousy original one, if
you find issues or don't like some changes feel free to adapt, thanks!