pub struct Logfile(_);Expand description
A Logfile type that wraps the timelog log file.
Implementations
sourceimpl Logfile
impl Logfile
sourcepub fn new(file: &str) -> Result<Self, PathError>
pub fn new(file: &str) -> Result<Self, PathError>
Creates a Logfile 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 clone_file(&self) -> String
pub fn clone_file(&self) -> String
Clone the filename
sourcepub fn add_line(&self, entry: &str) -> Result<(), PathError>
pub fn add_line(&self, entry: &str) -> Result<(), PathError>
Append the supplied line (including time stamp) to the timelog file
Errors
- Return
PathError::FileAccessif the file cannot be opened or created. - Return
PathError::FileWriteif the function fails to append to the file.
sourcepub fn add_task(&self, task: &str) -> Result<(), PathError>
pub fn add_task(&self, task: &str) -> Result<(), PathError>
Append the supplied task to the timelog file
Errors
- Return
PathError::FileAccessif the file cannot be opened or created. - Return
PathError::FileWriteif the function fails to append to the file.
sourcepub fn add_entry(&self, entry: &Entry) -> Result<(), PathError>
pub fn add_entry(&self, entry: &Entry) -> Result<(), PathError>
Append the supplied Entry to the timelog file
Errors
- Return
PathError::FileAccessif the file cannot be opened or created. - Return
PathError::FileWriteif the function fails to append to the file.
sourcepub fn add_comment(&self, comment: &str) -> Result<(), PathError>
pub fn add_comment(&self, comment: &str) -> Result<(), PathError>
Add a comment line to the timelog file
Errors
- Return
PathError::FileAccessif the file cannot be opened or created. - Return
PathError::FileWriteif the function fails to append to the file.
sourcepub fn add_event(&self, line: &str) -> Result<(), PathError>
pub fn add_event(&self, line: &str) -> Result<(), PathError>
Add a zero duration event to the timelog file
Errors
- Return
PathError::FileAccessif the file cannot be opened or created. - Return
PathError::FileWriteif the function fails to append to the file.
sourcepub fn discard_line(&self) -> Result<(), PathError>
pub fn discard_line(&self) -> Result<(), PathError>
Remove the most recent task from the logfile.
sourcepub fn reset_last_entry(&self) -> Result<(), Error>
pub fn reset_last_entry(&self) -> Result<(), Error>
Reset most recent entry to current date time.
sourcepub fn ignore_last_entry(&self) -> Result<(), Error>
pub fn ignore_last_entry(&self) -> Result<(), Error>
Ignore the most recent entry to current date time.
sourcepub fn rewrite_last_entry(&self, task: &str) -> Result<(), Error>
pub fn rewrite_last_entry(&self, task: &str) -> Result<(), Error>
Rewrite the text of the most recent entry.
sourcepub fn raw_last_line(&self) -> Option<String>
pub fn raw_last_line(&self) -> Option<String>
Return the unfiltered last line of the timelog file or None if we can’t.
sourcepub fn last_line(&self) -> Option<String>
pub fn last_line(&self) -> Option<String>
Return the last line of the timelog file or None if we can’t.
sourcepub fn last_entry(&self) -> Result<Entry, Error>
pub fn last_entry(&self) -> Result<Entry, Error>
Return the last line of the timelog file as an [`Entry’].
Errors
- Return
Error::InvalidEntryLineif the line is not correctly formatted.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Logfile
impl Send for Logfile
impl Sync for Logfile
impl Unpin for Logfile
impl UnwindSafe for Logfile
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