Struct timelog::stack::Stack

source ·
pub struct Stack(_);
Expand description

Represent the stack file on disk.

Implementations§

source§

impl Stack

source

pub fn new(file: &str) -> Result<Self, PathError>

Creates a Stack object wrapping the supplied file.

Errors
source

pub fn open(&self) -> Result<File, PathError>

Open the stack file for reading, return a File.

Errors
source

pub fn exists(&self) -> bool

Return true if the timelog file exists

source

pub fn clear(&self) -> Result<(), PathError>

Truncates the stack file, removing all items from the stack.

Errors
source

pub fn push(&self, task: &str) -> Result<(), PathError>

Adds a new event to the stack file.

Errors
source

pub fn pop(&self) -> Option<String>

Remove the most recent task from the stack file and return the task string.

source

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::StackPop if attempts to pop more items than exist in the stack file.
source

pub fn keep(&self, num: u32) -> Result<()>

Remove everything except the top num tasks from the stack.

Errors
source

pub fn process_down_stack<F>(&self, func: F) -> Result<()>where F: FnMut(usize, &str),

Process the stack top-down, passing the index and lines to the supplied function.

Errors
source

pub fn list(&self) -> String

Format the stack as a String.

The stack will be formatted such that the most recent item is listed first.

source

pub fn top(&self) -> Result<String>

Return the top of the stack as a String.

Errors

Trait Implementations§

source§

impl Debug for Stack

source§

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

Formats the value using the given formatter. Read more

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.