[pbs-devel] [PATCH proxmox-backup v2 4/7] tape: media_catalog: add local type aliases to make code more clear
Dietmar Maurer
dietmar at proxmox.com
Tue Jul 27 09:10:14 CEST 2021
comments below
On 7/22/21 3:41 PM, Dominik Csapak wrote:
> by adding some type aliases like 'type Store = String',
> the more complex types/return values are easier to read.
>
> For example
> HashMap<String, u64>
>
> turns into:
> HashMap<Snapshot, FileNr>
>
> since those types are not public, the generated cargo docs, do not
> contain them
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> src/tape/media_catalog.rs | 35 ++++++++++++++++++++---------------
> 1 file changed, 20 insertions(+), 15 deletions(-)
>
> diff --git a/src/tape/media_catalog.rs b/src/tape/media_catalog.rs
> index f7fcdd0a..296d1d2f 100644
> --- a/src/tape/media_catalog.rs
> +++ b/src/tape/media_catalog.rs
> @@ -31,9 +31,14 @@ use crate::{
> },
> };
>
> +type Store = String;
> +type Snapshot = String;
> +type FileNr = u64;
I am not a big fan , but OK.
> +type Chunk = [u8; 32];
> +
Introducing a special type here no sense - we use &[u8;32] for chunks
digests everywhere, so we want to replace that
everywhere (not only inside this file)
More information about the pbs-devel
mailing list