pub struct Stack(_);Expand description
Represent the stack file on disk.
Implementations
sourceimpl Stack
impl Stack
sourcepub fn new(file: &str) -> Result<Self, PathError>
pub fn new(file: &str) -> Result<Self, PathError>
Creates a Stack object wrapping the supplied file.
Errors
- Return
PathError::FilenameMissingif thefilehas no filename. - Return
PathError::InvalidPathif the path part offileis not a valid path.
sourcepub fn open(&self) -> Result<File, PathError>
pub fn open(&self) -> Result<File, PathError>
Open the stack file for reading, return a File.
Errors
- Return
PathError::FileAccessif unable to open the file.
sourcepub fn clear(&self) -> Result<(), PathError>
pub fn clear(&self) -> Result<(), PathError>
Truncates the stack file, removing all items from the stack.
Errors
- Return
PathError::FileAccessif the stack file is not accessible.
sourcepub fn push(&self, task: &str) -> Result<(), PathError>
pub fn push(&self, task: &str) -> Result<(), PathError>
Adds a new event to the stack file.
Errors
- Return
PathError::FileAccessif the stack file cannot be opened or created. - Return
PathError::FileWriteif the stack file cannot be written.
sourcepub fn pop(&self) -> Option<String>
pub fn pop(&self) -> Option<String>
Remove the most recent task from the stack file and return the task string.
sourcepub fn drop(&self, arg: u32) -> Result<()>
pub fn drop(&self, arg: u32) -> Result<()>
Remove one or more tasks from the stack file.
If arg is 0, remove one item.
If arg is a positive number, remove that many items from the stack.
Errors
- Return
Error::StackPopif attempts to pop more items than exist in the stack file.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Stack
impl Send for Stack
impl Sync for Stack
impl Unpin for Stack
impl UnwindSafe for Stack
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more