From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <s.hanreich@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 46E4993594
 for <pve-devel@lists.proxmox.com>; Tue,  9 Apr 2024 11:21:47 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 2E8B11A239
 for <pve-devel@lists.proxmox.com>; Tue,  9 Apr 2024 11:21:47 +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
 for <pve-devel@lists.proxmox.com>; Tue,  9 Apr 2024 11:21:46 +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 D094542DB7
 for <pve-devel@lists.proxmox.com>; Tue,  9 Apr 2024 11:21:45 +0200 (CEST)
Message-ID: <aac10011-ade8-45d9-89f9-f379bd4ac697@proxmox.com>
Date: Tue, 9 Apr 2024 11:21:45 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: pve-devel@lists.proxmox.com
References: <20240402171629.536804-1-s.hanreich@proxmox.com>
 <D0AFE6DIQNX9.14BZ44DY8PA7K@proxmox.com>
Content-Language: en-US
From: Stefan Hanreich <s.hanreich@proxmox.com>
In-Reply-To: <D0AFE6DIQNX9.14BZ44DY8PA7K@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.565 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 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
Subject: Re: [pve-devel] [RFC
 container/firewall/manager/proxmox-firewall/qemu-server 00/37] proxmox
 firewall nftables implementation
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Tue, 09 Apr 2024 09:21:47 -0000

On 4/3/24 12:46, Max Carrara wrote:
> Four overall things I want to mention:
> 
>   1. IMO a lot of the `pub` items should eventually be documented,
>      preferably once the actual series is out. I don't think we need to
>      be as thorough as e.g. the Rust STL's documentation, but I don't
>      think it would hurt if the overall functionality of things was
>      documented. (Of course, e.g. saying that `pub fn hostname()`
>      "gets the hostname" isn't necessary; but you get what I mean :P )

As already mentioned in-line I am currently working on this.

>   2. Constants and defaults should also be documented, simply because
>      it makes it easier to refer to those defaults if necessary. On top
>      of that, it's also more obvious if those constants / defaults ever
>      have to be changed for some reason. That way we would avoid
>      accidental semver-breakage. There's a more specific example inline.

see my in-line comments in the specific patch.

>   3. Would it perhaps actually make sense to use `thiserror` instead of
>      `anyhow`? I know we've speculated a little off list about this
>      already - I still am not 100% convinced that `thiserror` is
>      necessary, but then again, it would be quite nice in the library
>      crates, as you don't really need to propagate any `anyhow::Context`
>      anyways ...
> 
>      There's already `NftError` in proxmox-nftables that *could perhaps*
>      just be implemented via `thiserror`, I think.

Yes, error handling is probably the one big thing that needs some
overhauling. Since this was a monolithic crate that I've then extracted
into 3 different crates, anyhow was used throughout the whole codebase.

Not sure if thiserror is really necessary here, just like you, probably
just custom error types would suffice imo.

>   4. Some of the types (in particular in `proxmox-ve-config` and
>      `proxmox-nftables`) could use some more trait-deriving - a lot of
>      the structs and enums could benefit from deriving `PartialOrd`,
>      `Ord` and `Hash` for interoperability's sake [0]. While it's
>      probably unlikely that some types will ever be used as keys in a
>      hashmap, deriving the trait IMO doesn't hurt.
> 
>      A lot of types also implement `PartialEq` and `Eq` only for tests,
>      but IMO those traits could theoretically just always be implemented
>      for most of them.
> 
>      As this affects a lot of types I've decided to just sum this up
>      here by the way; if you need more concrete examples, please let me
>      know and I'll add respective comments inline.

Good point, I will review the structs/enums and add additional
derivations where applicable.