From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 659FC63245 for ; Tue, 9 Feb 2021 15:20:14 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5B9692E46B for ; Tue, 9 Feb 2021 15:20:14 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 367042E460 for ; Tue, 9 Feb 2021 15:20:10 +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 ED713454E9 for ; Tue, 9 Feb 2021 15:20:09 +0100 (CET) Date: Tue, 9 Feb 2021 15:20:08 +0100 From: Wolfgang Bumiller To: Stefan Reiter Cc: pbs-devel@lists.proxmox.com Message-ID: <20210209142008.efzb5tigctz3lmj6@olga.proxmox.com> References: <20210209120348.8359-1-s.reiter@proxmox.com> <20210209120348.8359-2-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210209120348.8359-2-s.reiter@proxmox.com> User-Agent: NeoMutt/20180716 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.045 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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. [aio.rs, mod.rs, sync.rs] Subject: Re: [pbs-devel] [PATCH pxar 1/2] make aio::Encoder actually behave with async X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2021 14:20:14 -0000 I'll have an in-depth look another time, just a quick noteinline: On Tue, Feb 09, 2021 at 01:03:47PM +0100, Stefan Reiter wrote: > To really use the encoder with async/await, it needs to support > SeqWrite implementations that are Send. This requires changing a whole > bunch of '&mut dyn SeqWrite' trait objects to instead take a 'T: > SeqWrite' generic parameter directly instead. Most of this is quite > straightforward, though incurs a lot of churn (FileImpl needs a generic > parameter now for example). > > The trickiest part is returning a new Encoder instance in > create_directory, as the trait object trick with > SeqWrite::as_trait_object doesn't work if SeqWrite is implemented for > generic '&mut S'. > > Instead, work with the generic object directly, and express the > owned/borrowed state in the Encoder (to avoid nested borrowing) as an > enum EncoderOutput. > > Add to the aio test to ensure the Encoder is now actually useable. > > Signed-off-by: Stefan Reiter > --- > src/encoder/aio.rs | 48 ++++++++--------- > src/encoder/mod.rs | 128 +++++++++++++++++++++++--------------------- > src/encoder/sync.rs | 28 ++++------ > 3 files changed, 101 insertions(+), 103 deletions(-) > > diff --git a/src/encoder/aio.rs b/src/encoder/aio.rs > index f4b96b3..6b90ce5 100644 > --- a/src/encoder/aio.rs > +++ b/src/encoder/aio.rs > @@ -13,12 +13,12 @@ use crate::Metadata; > /// > /// This is the `async` version of the `pxar` encoder. > #[repr(transparent)] > -pub struct Encoder<'a, T: SeqWrite + 'a> { > +pub struct Encoder<'a, T: SeqWrite + 'a + Send> { ^ This requirement should not strictly be necessary for Encoder to become Send. Send will propagate anyway. (You would only need this if you wanted to pass it as an `&dyn SeqWrite + Send` later on. Plus, I do not want to force this to be part of the API. It's very much possible to want to be able to reference non-Send local data in a single-threaded executor.