public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Max Carrara <m.carrara@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH pxar] decoder: sync: remove needless wrapper around `decoder::Contents`
Date: Fri, 11 Aug 2023 11:56:00 +0200	[thread overview]
Message-ID: <20230811095600.288467-1-m.carrara@proxmox.com> (raw)

Similarly to the `impl` for `tokio::io::AsyncRead` in `decoder::aio`,
this implements the `std::io::Read` trait on `decoder::Contents`
directly while removing the wrapper.

This allows `decoder::Contents` to be used in both synchronous
and asynchronous contexts.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
---
 src/decoder/sync.rs | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/decoder/sync.rs b/src/decoder/sync.rs
index 5597a03..be576f8 100644
--- a/src/decoder/sync.rs
+++ b/src/decoder/sync.rs
@@ -5,7 +5,7 @@ use std::path::Path;
 use std::pin::Pin;
 use std::task::{Context, Poll};

-use crate::decoder::{self, SeqRead};
+use crate::decoder::{self, Contents, SeqRead};
 use crate::util::poll_result_once;
 use crate::Entry;

@@ -69,7 +69,7 @@ impl<T: SeqRead> Decoder<T> {

     /// Get a reader for the contents of the current entry, if the entry has contents.
     pub fn contents(&mut self) -> Option<Contents<T>> {
-        self.inner.content_reader().map(|inner| Contents { inner })
+        self.inner.content_reader()
     }

     /// Get the size of the current contents, if the entry has contents.
@@ -118,13 +118,8 @@ impl<T: io::Read> SeqRead for StandardReader<T> {
     }
 }

-/// Reader for file contents inside a pxar archive.
-pub struct Contents<'a, T: SeqRead> {
-    inner: decoder::Contents<'a, T>,
-}
-
-impl<'a, T: SeqRead> io::Read for Contents<'a, T> {
+impl<'a, T: SeqRead> io::Read for decoder::Contents<'a, T> {
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
-        poll_result_once(super::seq_read(&mut self.inner, buf))
+        poll_result_once(super::seq_read(self.input, buf))
     }
 }
--
2.39.2





             reply	other threads:[~2023-08-11  9:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11  9:56 Max Carrara [this message]
2023-08-22 11:35 ` Wolfgang Bumiller
2023-08-24  9:47   ` Max Carrara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230811095600.288467-1-m.carrara@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal