Struct timelog::entry::Entry

source ·
pub struct Entry { /* private fields */ }
Expand description

Representation of an entry in the log

Objects of this type represent individual lines in the timelog.txt file. Each Entry has a date and time stamp, an optional project, and a task.

Implementations§

source§

impl Entry

source

pub fn task_breakdown(entry_text: &str) -> (Option<String>, Option<String>)

Parse the entry line text into the task name and detail parts if they exist.

source

pub fn is_stop_line(line: &str) -> bool

Return true if the supplied string looks like a stop line.

source

pub fn datetime_from_line(line: &str) -> Option<&str>

Extract a date/time string from a task line

source

pub fn date_from_line(line: &str) -> Option<&str>

Extract a date string from a task line

source

pub fn extract_year(line: &str) -> Option<i32>

Return the year for the supplied entry line, if any.

source

pub fn is_comment_line(line: &str) -> bool

Return true if the supplied line is a comment.

source§

impl Entry

source

pub fn new(entry_text: &str, time: DateTime) -> Self

Create a new Entry representing the supplied task at the supplied time.

source

pub fn new_marked(entry_text: &str, time: DateTime, kind: EntryKind) -> Self

Create a new Entry representing the supplied task at the supplied time and optional mark.

source

pub fn new_stop(time: DateTime) -> Self

Create a new Entry representing a stop entry for the supplied DateTime

source

pub fn from_line(line: &str) -> Result<Self, EntryError>

Create a new Entry representing the entry from the supplied line.

This entry must be formatted as described in Format.md.

Errors

Return an EntryError if the line is empty or formatted incorrectly.

source§

impl Entry

source

pub fn project(&self) -> Option<&str>

Return the &str designated as the project, if any, from the Entry.

source

pub fn entry_text(&self) -> &str

Return the &str containing all of the Entry except the time and date.

source

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

Return the String containing all of the Entry except the time and date.

source

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

Return the String containing all of the Entry except the time and date.

source

pub fn task_and_detail(&self) -> (Option<String>, Option<String>)

Return the String containing all of the Entry except the time and date.

source

pub fn epoch(&self) -> i64

Return the time for the start of the Entry in epoch seconds.

source

pub fn date(&self) -> Date

Return the date for the start of the Entry as a Date

source

pub fn date_time(&self) -> DateTime

Return the time for the start of the Entry as a DateTime

source

pub fn timestamp(&self) -> String

Return the time for the start of the Entry as a DateTime

source

pub fn stamp(&self) -> String

Return the date stamp of the Entry in ‘YYYY-MM-DD’ format.

source

pub fn is_start(&self) -> bool

Return true if this a start Entry.

source

pub fn is_stop(&self) -> bool

Return true if this was a stop Entry.

source

pub fn is_ignore(&self) -> bool

Return true if this was an ignored Entry.

source

pub fn ignore(&self) -> Self

Return an ignored Entry converted from this one.

source

pub fn is_event(&self) -> bool

Return true if this was a event Entry.

source§

impl Entry

source

pub fn change_date_time(&self, date_time: DateTime) -> Self

Return a new copy of the current Entry with the date and time reset the the supplied value.

source

pub fn change_text(&self, task: &str) -> Self

Return a new copy of the current Entry with the date and time reset the the supplied value.

source

pub fn to_day_end(&self) -> Self

Return a new Entry timestamped as the end of this date

Trait Implementations§

source§

impl Clone for Entry

source§

fn clone(&self) -> Entry

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Entry

source§

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

Formats the value using the given formatter. Read more
source§

impl Display for Entry

source§

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

Format the Entry formatted as described in Format.md.

source§

impl PartialEq<Entry> for Entry

source§

fn eq(&self, other: &Entry) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Entry> for Entry

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists.

1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for Entry

source§

impl StructuralEq for Entry

source§

impl StructuralPartialEq for Entry

Auto Trait Implementations§

§

impl RefUnwindSafe for Entry

§

impl Send for Entry

§

impl Sync for Entry

§

impl Unpin for Entry

§

impl UnwindSafe for Entry

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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.