pub struct FileSet { /* private fields */ }Implementations§
Source§impl FileSet
impl FileSet
Sourcepub fn new(paths: Vec<PathBuf>) -> Self
pub fn new(paths: Vec<PathBuf>) -> Self
Construct with the initial path list. paths must be non-empty
for navigation to make sense; an empty list is technically valid
(stdin-source startup uses an empty FileSet) but all navigation
methods then return errors or None.
pub fn current(&self) -> Option<&Path>
pub fn current_index(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn set_current_index(&mut self, index: usize)
pub fn set_current_index(&mut self, index: usize)
Set the cursor directly. Out-of-range indices are clamped to the last entry (or no-op if the list is empty).
Sourcepub fn next(&mut self) -> Result<&Path, FileSetError>
pub fn next(&mut self) -> Result<&Path, FileSetError>
Advance to the next file. Returns the new current path on success
or NoNextFile if already at the last entry.
Sourcepub fn prev(&mut self) -> Result<&Path, FileSetError>
pub fn prev(&mut self) -> Result<&Path, FileSetError>
Move to the previous file. Returns the new current path on success
or NoPreviousFile if already at the first entry.
Sourcepub fn first(&mut self) -> Option<&Path>
pub fn first(&mut self) -> Option<&Path>
Jump to the first file. Returns the current path after the move,
or None if the list is empty. Returns Option (not Result)
because jumping to the boundary is always idempotent — there’s
no “no first file” failure mode like there is for next.
Sourcepub fn last(&mut self) -> Option<&Path>
pub fn last(&mut self) -> Option<&Path>
Jump to the last file. Returns the current path after the move,
or None if the list is empty. See first for the rationale
behind Option rather than Result.
Sourcepub fn append_and_switch(&mut self, path: PathBuf) -> &Path
pub fn append_and_switch(&mut self, path: PathBuf) -> &Path
Append path to the list and switch the cursor to it.
Sourcepub fn delete_current(&mut self) -> Result<&Path, FileSetError>
pub fn delete_current(&mut self) -> Result<&Path, FileSetError>
Delete the current entry and move the cursor to the next file (or
back to the previous if we were at the end). Returns the new
current path. Errors with WouldEmpty when only one file remains.