hevy 0.1.0

An async Rust client library for the Hevy public API (https://api.hevyapp.com/docs/)
Documentation
use serde::{Deserialize, Serialize};

/// A folder used to organize [`crate::Routine`]s.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RoutineFolder {
    /// The routine folder ID.
    pub id: i64,
    /// The routine folder index, describing the order of the folder in the list.
    #[serde(default)]
    pub index: i64,
    /// The routine folder title.
    #[serde(default)]
    pub title: String,
    /// ISO 8601 timestamp of when the folder was last updated.
    #[serde(default)]
    pub updated_at: String,
    /// ISO 8601 timestamp of when the folder was created.
    #[serde(default)]
    pub created_at: String,
}

/// A page of [`RoutineFolder`]s, as returned by [`crate::HevyClient::list_routine_folders`].
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RoutineFoldersPage {
    /// The current page number.
    pub page: u32,
    /// The total number of pages available.
    pub page_count: u32,
    /// The routine folders on this page.
    #[serde(default)]
    pub routine_folders: Vec<RoutineFolder>,
}

/// The routine folder fields accepted when creating a new folder.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct NewRoutineFolder {
    /// The title of the routine folder.
    pub title: String,
}

impl NewRoutineFolder {
    /// Creates a new routine folder payload with the given title.
    pub fn new(title: impl Into<String>) -> Self {
        Self { title: title.into() }
    }
}

/// The request body used to create a new routine folder.
///
/// The folder will be created at index 0, and all other folders will have
/// their indexes incremented.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CreateRoutineFolderRequest {
    /// The routine folder to create.
    pub routine_folder: NewRoutineFolder,
}

impl CreateRoutineFolderRequest {
    /// Wraps a [`NewRoutineFolder`] in the request body envelope expected by the API.
    pub fn new(routine_folder: NewRoutineFolder) -> Self {
        Self { routine_folder }
    }
}