Struct Logfile

Source
pub struct Logfile(/* private fields */);
Expand description

A Logfile type that wraps the timelog log file.

Implementations§

Source§

impl Logfile

Source

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

Creates a Logfile object wrapping the supplied file.

§Errors
Source

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

Open the log file, return a File.

§Errors
Source

pub fn clone_file(&self) -> String

Clone the filename

Source

pub fn exists(&self) -> bool

Return true if the timelog file exists

Source

pub fn add_line(&self, entry: &str) -> Result<(), PathError>

Append the supplied line (including time stamp) to the timelog file

§Errors
Source

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

Append the supplied task to the timelog file

§Errors
Source

pub fn add_entry(&self, entry: &Entry) -> Result<(), PathError>

Append the supplied Entry to the timelog file

§Errors
Source

pub fn add_comment(&self, comment: &str) -> Result<(), PathError>

Add a comment line to the timelog file

§Errors
Source

pub fn add_event(&self, line: &str) -> Result<(), PathError>

Add a zero duration event to the timelog file

§Errors
Source

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

Remove the most recent task from the logfile.

§Errors
Source

pub fn reset_last_entry(&self) -> Result<(), Error>

Reset most recent entry to current date time.

§Errors
Source

pub fn ignore_last_entry(&self) -> Result<(), Error>

Ignore the most recent entry to current date time.

§Errors
Source

pub fn rewrite_last_entry(&self, task: &str) -> Result<(), Error>

Rewrite the text of the most recent entry.

§Errors
Source

pub fn retime_last_entry(&self, time: Time) -> Result<(), Error>

Reset the time of the most recent entry.

§Errors
Source

pub fn rewind_last_entry(&self, minutes: NonZeroU32) -> Result<(), Error>

Shift the time of the most recent entry back the specified number of minutes.

§Errors
Source

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

Return the unfiltered last line of the timelog file or None if we can’t.

Source

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

Return the last line of the timelog file or None if we can’t.

Source

pub fn last_entry(&self) -> Result<Entry, Error>

Return the last line of the timelog file as an Entry.

§Errors
Source

pub fn problems(&self) -> Vec<Problem>

Return a Vec of problems found with the file.

If the Vec is empty, there are no problems.

Trait Implementations§

Source§

impl Debug for Logfile

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Source§

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.