Struct Files

Source
pub struct Files<'a, R: Read + Seek> { /* private fields */ }
Expand description

A collection of files deserialized by parse.

Implementations§

Source§

impl<'a, R: Read + Seek> Files<'a, R>

Source

pub fn all(&mut self) -> &mut [File<'a, R>]

Get all the files.

Examples found in repository?
examples/main.rs (line 35)
27fn extract_all<P1: AsRef<Path>, P2: AsRef<Path>>(
28    path: P1,
29    dest: Option<P2>,
30) -> Result<(), deserialize::Error> {
31    let mut file = fs::File::open(path).map_err(deserialize::Error::Reader)?;
32
33    let ref_cell = RefCell::new(&mut file);
34
35    for file in parse(&ref_cell)?.all() {
36        let path = match dest.as_ref() {
37            Some(dest) => Cow::Owned(dest.as_ref().join(file.path())),
38            None => Cow::Borrowed(file.path()),
39        };
40
41        let mut dir = fs::DirBuilder::new();
42        dir.recursive(true);
43        dir.create(&path.with_file_name(""))
44            .map_err(deserialize::Error::Reader)?;
45
46        let mut dest = fs::File::create(&path).map_err(deserialize::Error::Reader)?;
47
48        io::copy(file, &mut dest).map_err(deserialize::Error::Reader)?;
49    }
50
51    Ok(())
52}
Source

pub fn filter<F: FnMut(&Path) -> bool>( &mut self, filter: F, ) -> Vec<&mut File<'a, R>>

Filter through all files by path with filter.

Trait Implementations§

Source§

impl<'a, R: Debug + Read + Seek> Debug for Files<'a, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, R> Freeze for Files<'a, R>

§

impl<'a, R> !RefUnwindSafe for Files<'a, R>

§

impl<'a, R> !Send for Files<'a, R>

§

impl<'a, R> !Sync for Files<'a, R>

§

impl<'a, R> Unpin for Files<'a, R>

§

impl<'a, R> !UnwindSafe for Files<'a, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.