]> git.proxmox.com Git - pxar.git/commitdiff
Decoder<StandardReader<T>>: allow access to input
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 18 Sep 2020 09:32:43 +0000 (11:32 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 18 Sep 2020 09:32:43 +0000 (11:32 +0200)
We need this to query the status of the input when decode fails.

src/decoder/mod.rs
src/decoder/sync.rs

index 3e8410789bd52c5906f69f34195ed27a2e41c240..fcc2dd9c3234b0e9b8c29da1f8305572c32c8cad 100644 (file)
@@ -194,6 +194,10 @@ impl<I: SeqRead> DecoderImpl<I> {
         Self::new_full(input, "/".into()).await
     }
 
+    pub(crate) fn input(&self) -> &I {
+        &self.input
+    }
+
     pub(crate) async fn new_full(input: I, path: PathBuf) -> io::Result<Self> {
         let this = DecoderImpl {
             input,
index a7afda1b561e4d2ce39d0245e5c683bbba641e57..85b48659724974a2f67a74a830275cf53fbc69ac 100644 (file)
@@ -28,6 +28,10 @@ impl<T: io::Read> Decoder<StandardReader<T>> {
     pub fn from_std(input: T) -> io::Result<Self> {
         Decoder::new(StandardReader::new(input))
     }
+
+    pub fn input(&mut self) -> &T {
+        self.inner.input().inner()
+    }
 }
 
 impl Decoder<StandardReader<std::fs::File>> {
@@ -95,6 +99,10 @@ impl<T: io::Read> StandardReader<T> {
     pub fn new(inner: T) -> Self {
         Self { inner }
     }
+
+    pub fn inner(&self) -> &T {
+        &self.inner
+    }
 }
 
 impl<T: io::Read> SeqRead for StandardReader<T> {