Skip to main content

TimeTracks

Struct TimeTracks 

Source
pub struct TimeTracks<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> TimeTracks<'a>

Source

pub fn client(&self) -> &'a Client

The client this service sends through.

Source

pub async fn create( &self, body: &TimeTrackRequestContent, ) -> Result<CreateTimeTrackResponseContent, Error>

Record a finished stretch of time.

JSON callers send the fields flat; Rails wraps them into calendar_time_track itself.

Source

pub async fn delete(&self, time_track_id: i64) -> Result<(), Error>

Delete a time track. The id is the recording’s.

Source

pub async fn get_ongoing( &self, ) -> Result<Option<GetOngoingTimeTrackResponseContent>, Error>

Get the ongoing time track (404 = no active track; see ADR-004)

Source

pub async fn list( &self, params: &ListTimeTracksParams, ) -> Result<Page<ListTimeTracksResponseContent>, Error>

List tracked time — completed tracks only, newest-ended first.

A running track is not here; read that with GetOngoingTimeTrack. The next page, if any, is a Link header, and the last page carries none, so a nil Link is the end of the list rather than an error.

category_id narrows the list to one category and 404s if the calendar has no category by that id.

The calendar’s categories come back alongside the tracks, so showing or applying the filter does not need ListTimeTrackCategories as well.

Source

pub async fn list_categories( &self, ) -> Result<ListTimeTrackCategoriesResponseContent, Error>

List the calendar’s time track categories, alphabetically

Source

pub async fn start(&self) -> Result<StartTimeTrackResponseContent, Error>

Start a new time track. Takes no body: haystack’s Calendar::OngoingTimeTracksController#create ignores request parameters and starts a track with defaults; use UpdateTimeTrack to set notes and category_title, which also stops the track.

Source

pub async fn update( &self, time_track_id: i64, body: &UpdateTimeTrackRequestContent, ) -> Result<UpdateTimeTrackResponseContent, Error>

Update a time track (stop by setting ends_at to current time).

Every update completes the track, whether or not ends_at is sent, so this cannot be used to adjust a running track: it stops it.

Only the fields sent are written, so a partial update leaves the rest of the track alone. A starts_at or ends_at the server cannot parse is a 400, not a 422.

Source§

impl TimeTracks<'_>

Source

pub async fn start_tracking(&self) -> Result<Recording, Error>

Starts a time track. It takes nothing: HEY ignores the request body here and starts a track with defaults. Notes and a category come later, with TimeTracks::update or TimeTracks::stop_and_file, both of which also stop the track.

This is TimeTracks::start with the one refusal it can meet named: a track already running answers 409, which arrives as crate::ErrorCode::Conflict carrying HEY’s own message, so a caller can branch on it rather than read a generic API error.

Source

pub async fn stop(&self, time_track_id: i64) -> Result<(), Error>

Stops the running time track by setting its end to now.

Source

pub async fn stop_and_file( &self, time_track_id: i64, category_title: Option<&str>, ) -> Result<(), Error>

Stops a time track and files it under a category in the one request, creating the category if HEY has none by that name. No category stops the track without filing it, which is what TimeTracks::stop does.

Filing is only ever part of stopping: HEY completes a track on every update, so there is no such thing as setting a category on a track that keeps running.

It sends the same PUT TimeTracks::update does, but announces itself to the client’s hooks as StopTimeTrack rather than UpdateTimeTrack, so a gating policy can allow one without the other.

Source

pub async fn create_category(&self, title: &str) -> Result<(), Error>

Adds a category to file tracks under.

Source

pub async fn update_category( &self, category_id: i64, title: &str, ) -> Result<(), Error>

Renames a category.

Source

pub async fn delete_category(&self, category_id: i64) -> Result<(), Error>

Removes a category. The tracks filed under it stay, uncategorized.

Source

pub async fn export(&self) -> Result<Bytes, Error>

Every completed time track as CSV, newest first, under the columns Start, End, Duration, Category and Notes. HEY streams this as a file rather than a document.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for TimeTracks<'a>

§

impl<'a> !UnwindSafe for TimeTracks<'a>

§

impl<'a> Freeze for TimeTracks<'a>

§

impl<'a> Send for TimeTracks<'a>

§

impl<'a> Sync for TimeTracks<'a>

§

impl<'a> Unpin for TimeTracks<'a>

§

impl<'a> UnsafeUnpin for TimeTracks<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more