pub struct Logfile(/* private fields */);
Expand description
A Logfile
type that wraps the timelog log file.
Implementations§
Source§impl 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::FilenameMissing
if thefile
has no filename. - Return
PathError::InvalidPath
if the path part offile
is not a valid path. - Return
PathError::InvalidTimelogPath
if stack path is invalid.
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::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if 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::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if 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::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if 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::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if 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::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if 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.
§Errors
- Return
PathError::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if the function fails to append to the file.
Sourcepub fn reset_last_entry(&self) -> Result<(), Error>
pub fn reset_last_entry(&self) -> Result<(), Error>
Reset most recent entry to current date time.
§Errors
- Return
PathError::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if the function fails to append to the file.
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.
§Errors
- Return
PathError::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if the function fails to append to the file.
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.
§Errors
- Return
PathError::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if the function fails to append to the file.
Sourcepub fn retime_last_entry(&self, time: Time) -> Result<(), Error>
pub fn retime_last_entry(&self, time: Time) -> Result<(), Error>
Reset the time of the most recent entry.
§Errors
- Return
PathError::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if the function fails to append to the file. - Return
Error::InvalidWasArgument
if supplied time is not parsable.
Sourcepub fn rewind_last_entry(&self, minutes: NonZeroU32) -> Result<(), Error>
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
- Return
PathError::FileAccess
if the file cannot be opened or created. - Return
PathError::FileWrite
if the function fails to append to the file. - Return
Error::InvalidWasArgument
if supplied time is not parsable.
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::InvalidEntryLine
if the line is not correctly formatted.