pub struct Files<'a, R: Read + Seek> { /* private fields */ }
Expand description
A collection of files deserialize
d by parse
.
Implementations§
Source§impl<'a, R: Read + Seek> Files<'a, R>
impl<'a, R: Read + Seek> Files<'a, R>
Sourcepub fn all(&mut self) -> &mut [File<'a, R>]
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}
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more