pub struct ArchiveStack { /* private fields */ }
Expand description
A utility struct to keep track of the current archive stack. This is useful when processing nested archives - it supports pushing and popping archives from the stack, and provides the current nested path - including all previous nested paths.
§Example
let mut stack = ArchiveStack::new();
stack.push_details(EntryDetails::new("first.tar", 5));
stack.push_details(EntryDetails::new("second.tar", 10));
stack.push_details(EntryDetails::new("third.tar", 7));
assert_eq!(stack.root_path(), Path::new("first.tar"));
assert_eq!(stack.nested_path(), Path::new("second.tar/third.tar"));
assert_eq!(stack.current_depth(), 3);
stack.pop_details();
assert_eq!(stack.nested_path(), Path::new("second.tar"));
Implementations§
Source§impl ArchiveStack
impl ArchiveStack
pub fn new() -> Self
pub fn last_entry(&self) -> Option<&EntryDetails>
pub fn push_details(&mut self, details: EntryDetails)
pub fn pop_details(&mut self) -> Option<EntryDetails>
pub fn current_depth(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn full_path(&self) -> PathBuf
pub fn root_path(&self) -> &Path
pub fn nested_path(&self) -> PathBuf
pub fn nested_path_iter(&self) -> impl Iterator<Item = &Path>
Trait Implementations§
Source§impl Debug for ArchiveStack
impl Debug for ArchiveStack
Source§impl Default for ArchiveStack
impl Default for ArchiveStack
Source§fn default() -> ArchiveStack
fn default() -> ArchiveStack
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ArchiveStack
impl RefUnwindSafe for ArchiveStack
impl Send for ArchiveStack
impl Sync for ArchiveStack
impl Unpin for ArchiveStack
impl UnwindSafe for ArchiveStack
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