From d8a4ae7307cd0a60363f796713339d8ca271db36 Mon Sep 17 00:00:00 2001 From: Brian Lachniet Date: Wed, 16 Nov 2022 22:05:19 -0500 Subject: [PATCH] Add some documentation --- src/api.rs | 4 ++++ src/error.rs | 4 ++++ src/svc.rs | 2 ++ 3 files changed, 10 insertions(+) diff --git a/src/api.rs b/src/api.rs index adf7592..bfff3d8 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,3 +1,5 @@ +//! Low-level client for interacting with the [Toggl API](https://developers.track.toggl.com/docs/). + use chrono::NaiveDate; use reqwest::header; use serde::{Deserialize, Serialize}; @@ -5,12 +7,14 @@ use serde_json::Number; static BASE_API_URL: &str = "https://api.track.toggl.com/api/v9"; +/// Low-level client for interacting with the [Toggl API](https://developers.track.toggl.com/docs/). pub struct Client { c: reqwest::blocking::Client, token: String, } impl Client { + /// Creates a new client with the given API token. pub fn new(token: String) -> Result { let mut headers = header::HeaderMap::new(); diff --git a/src/error.rs b/src/error.rs index 08af0fe..78ecc56 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,9 +1,13 @@ +//! Defines the error type for top-level CLI commands. + +/// Error type for top-level CLI commands. #[derive(Debug)] pub struct Error { pub message: String, } impl Error { + /// Creates a new entry with the given message. pub fn new(message: String) -> Self { Self { message } } diff --git a/src/svc.rs b/src/svc.rs index cc572b6..d57d0c5 100644 --- a/src/svc.rs +++ b/src/svc.rs @@ -1,3 +1,5 @@ +//! High-level client for interacting with Toggl. Uses the [api]. + use crate::api; use chrono::{DateTime, Duration, TimeZone, Utc};