From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pbs-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 592641FF38F
	for <inbox@lore.proxmox.com>; Tue, 21 May 2024 12:05:48 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id B3B4115E60;
	Tue, 21 May 2024 12:06:04 +0200 (CEST)
Message-ID: <8e19f4c5-6d8d-4ff9-96d9-44342f6d25f4@proxmox.com>
Date: Tue, 21 May 2024 12:06:00 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird Beta
To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>, Christian Ebner <c.ebner@proxmox.com>
References: <20240514103421.289431-1-c.ebner@proxmox.com>
 <20240514103421.289431-5-c.ebner@proxmox.com>
Content-Language: en-US
From: Dominik Csapak <d.csapak@proxmox.com>
In-Reply-To: <20240514103421.289431-5-c.ebner@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.016 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: [pbs-devel] [PATCH v6 pxar 04/14] encoder: add optional output
 writer for file payloads
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>
Reply-To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

one small comment inline

On 5/14/24 12:33, Christian Ebner wrote:
[snip]
> diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs
> index da41733..99c3758 100644
> --- a/src/encoder/mod.rs
> +++ b/src/encoder/mod.rs
> @@ -17,7 +17,7 @@ use endian_trait::Endian;
>   
>   use crate::binary_tree_array;
>   use crate::decoder::{self, SeqRead};
> -use crate::format::{self, GoodbyeItem};
> +use crate::format::{self, GoodbyeItem, PayloadRef};
>   use crate::Metadata;
>   
>   pub mod aio;
> @@ -221,6 +221,9 @@ struct EncoderState {
>   
>       /// We need to keep track how much we have written to get offsets.
>       write_position: u64,
> +
> +    /// Track the bytes written to the payload writer
> +    payload_write_position: u64,
>   }
>   
>   impl EncoderState {
> @@ -278,6 +281,7 @@ impl<'a, T> std::convert::From<&'a mut T> for EncoderOutput<'a, T> {
>   /// synchronous or `async` I/O objects in as output.
>   pub(crate) struct EncoderImpl<'a, T: SeqWrite + 'a> {
>       output: EncoderOutput<'a, T>,
> +    payload_output: EncoderOutput<'a, Option<T>>,
>       state: EncoderState,
>       parent: Option<&'a mut EncoderState>,
>       finished: bool,
> @@ -306,12 +310,14 @@ impl<'a, T: SeqWrite + 'a> EncoderImpl<'a, T> {
>       pub async fn new(
>           output: EncoderOutput<'a, T>,
>           metadata: &Metadata,
> +        payload_output: Option<T>,
>       ) -> io::Result<EncoderImpl<'a, T>> {
>           if !metadata.is_dir() {
>               io_bail!("directory metadata must contain the directory mode flag");
>           }
>           let mut this = Self {
>               output,
> +            payload_output: EncoderOutput::Owned(None),
>               state: EncoderState::default(),
>               parent: None,
>               finished: false,
> @@ -323,6 +329,10 @@ impl<'a, T: SeqWrite + 'a> EncoderImpl<'a, T> {
>           this.encode_metadata(metadata).await?;
>           this.state.files_offset = this.position();
>   
> +        if let Some(payload_output) = payload_output {
> +            this.payload_output = EncoderOutput::Owned(Some(payload_output));
> +        }
> +

you could do that above directly in the payload_output property
since you do change it to that anyway in patch 12/14

and should be semantically the same

>           Ok(this)
>       }
>   


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel