Skip to main content

TimeEntry

Struct TimeEntry 

Source
pub struct TimeEntry {
    pub id: String,
    pub duration_minutes: Option<i64>,
    pub date: Option<String>,
    pub author: String,
    pub note: Option<String>,
    pub extensions: TimeEntryExtensions,
}
Expand description

One current time entry: actual effort recorded against one issue.

The fields are the mission’s confirmed shape (data-model §1, C-002): id is the stable identity that is never reused, duration_minutes the effort at documented minute precision, date an optional calendar date, author the required attribution, note optional free text, and extensions whatever else the file carries. An entry is not an estimate, a status or an ownership value, and no operation on one may change those (C-008).

Eq/Ord are the file’s own notions: equality is field-by-field (with the extensions compared by canonical render) and ordering is order_key — dated entries oldest first, undated last, ties by stable id — with every remaining field compared afterwards so the order is a total order consistent with equality. Surfaces that display entries in a deterministic order (data-model §6) sort by that order.

Fields§

§id: String

The stable id: identity for edits, deletions and History references.

Required for a valid entry and refused when blank, but default’d on read so an entry a hand edit emptied still parses and is reported instead of failing the issue (see the module docs).

§duration_minutes: Option<i64>

The effort, in whole minutes at or above zero.

Option for the same diagnosability reason: a valid entry always carries one, and an absent one is refused by name rather than read as zero minutes.

§date: Option<String>

The calendar date the effort belongs to, YYYY-MM-DD.

Optional and skipped when absent, so an entry without a date round-trips without gaining a key, and so an issue that carries no entry at all is unaffected by this field’s existence.

§author: String

Who recorded the effort: an identity in the shape an issue’s assignee tolerates (a bare handle, or Name <email>), verbatim.

§note: Option<String>

Optional free text, preserved verbatim.

§extensions: TimeEntryExtensions

Unknown metadata, preserved verbatim.

Implementations§

Source§

impl TimeEntry

Source

pub fn new( id: impl Into<String>, duration_minutes: i64, date: Option<String>, author: impl Into<String>, note: Option<String>, ) -> Result<Self, Vec<TimeEntryError>>

Build a valid entry, refusing the same values Self::validate refuses.

Returns every problem at once, in field order, rather than the first: a caller fixing an entry should not have to resubmit it once per field.

Source

pub fn minutes(&self) -> Option<i64>

The duration when it is present and at or above zero.

None is exactly the malformed state Self::problems reports, so a caller that has validated the entry can add this to a total and a caller that has not cannot mistake a missing duration for zero minutes.

Source

pub fn order_key(&self) -> (bool, Option<&str>, &str)

The deterministic display order (data-model §6).

Dated entries oldest first, undated last, ties broken by the stable id. Comparing the whole tuple is how Ord keeps its order consistent with equality.

Source

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

Every field-level problem, in field order; empty means valid.

Source

pub fn is_valid(&self) -> bool

Whether the entry has no field-level problems.

Source

pub fn validate(&self) -> Result<(), Vec<TimeEntryError>>

Refuse the entry unless every field is valid.

Err carries all of Self::problems, not just the first, so a diagnostic surface can report the complete field set.

Trait Implementations§

Source§

impl Clone for TimeEntry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TimeEntry

Source§

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

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

impl<'de> Deserialize<'de> for TimeEntry

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for TimeEntry

Source§

impl Ord for TimeEntry

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for TimeEntry

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for TimeEntry

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for TimeEntry

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TimeEntry

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.