pxar: decoder: take ownership of underlying reader
By taking ownership it is easier to move the decoder into another struct, e.g. into a session context in fuse. Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
parent
f50b4fd6a0
commit
7750b7f2b7
@ -21,17 +21,17 @@ pub struct DirectoryEntry {
|
||||
}
|
||||
|
||||
// This one needs Read+Seek
|
||||
pub struct Decoder<'a, R: Read + Seek, F: Fn(&Path) -> Result<(), Error>> {
|
||||
inner: SequentialDecoder<'a, R, F>,
|
||||
pub struct Decoder<R: Read + Seek, F: Fn(&Path) -> Result<(), Error>> {
|
||||
inner: SequentialDecoder<R, F>,
|
||||
root_start: u64,
|
||||
root_end: u64,
|
||||
}
|
||||
|
||||
const HEADER_SIZE: u64 = std::mem::size_of::<PxarHeader>() as u64;
|
||||
|
||||
impl <'a, R: Read + Seek, F: Fn(&Path) -> Result<(), Error>> Decoder<'a, R, F> {
|
||||
impl <R: Read + Seek, F: Fn(&Path) -> Result<(), Error>> Decoder<R, F> {
|
||||
|
||||
pub fn new(reader: &'a mut R, callback: F) -> Result<Self, Error> {
|
||||
pub fn new(mut reader: R, callback: F) -> Result<Self, Error> {
|
||||
|
||||
let root_end = reader.seek(SeekFrom::End(0))?;
|
||||
|
||||
|
@ -33,8 +33,8 @@ use crate::tools::acl;
|
||||
use crate::tools::xattr;
|
||||
|
||||
// This one need Read, but works without Seek
|
||||
pub struct SequentialDecoder<'a, R: Read, F: Fn(&Path) -> Result<(), Error>> {
|
||||
reader: &'a mut R,
|
||||
pub struct SequentialDecoder<R: Read, F: Fn(&Path) -> Result<(), Error>> {
|
||||
reader: R,
|
||||
feature_flags: u64,
|
||||
allow_existing_dirs: bool,
|
||||
skip_buffer: Vec<u8>,
|
||||
@ -43,9 +43,9 @@ pub struct SequentialDecoder<'a, R: Read, F: Fn(&Path) -> Result<(), Error>> {
|
||||
|
||||
const HEADER_SIZE: u64 = std::mem::size_of::<PxarHeader>() as u64;
|
||||
|
||||
impl <'a, R: Read, F: Fn(&Path) -> Result<(), Error>> SequentialDecoder<'a, R, F> {
|
||||
impl <R: Read, F: Fn(&Path) -> Result<(), Error>> SequentialDecoder<R, F> {
|
||||
|
||||
pub fn new(reader: &'a mut R, feature_flags: u64, callback: F) -> Self {
|
||||
pub fn new(reader: R, feature_flags: u64, callback: F) -> Self {
|
||||
let skip_buffer = vec::undefined(64*1024);
|
||||
|
||||
Self {
|
||||
@ -61,8 +61,8 @@ impl <'a, R: Read, F: Fn(&Path) -> Result<(), Error>> SequentialDecoder<'a, R, F
|
||||
self.allow_existing_dirs = allow;
|
||||
}
|
||||
|
||||
pub (crate) fn get_reader_mut(&mut self) -> & mut R {
|
||||
self.reader
|
||||
pub (crate) fn get_reader_mut(&mut self) -> &mut R {
|
||||
&mut self.reader
|
||||
}
|
||||
|
||||
pub (crate) fn read_item<T: Endian>(&mut self) -> Result<T, Error> {
|
||||
|
Loading…
Reference in New Issue
Block a user