From 3e722076790a35480ddf6881e07e95acc17beed2 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sun, 10 Nov 2024 05:09:18 +0100 Subject: [PATCH] Adds some doc --- src/error_handling.rs | 3 --- src/votes/events.rs | 33 +++++++++++++++------------------ 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/error_handling.rs b/src/error_handling.rs index e9844d9..852b161 100644 --- a/src/error_handling.rs +++ b/src/error_handling.rs @@ -11,9 +11,6 @@ use poise::serenity_prelude; use thiserror::Error; use uuid::Uuid; -// // Since the errors themselves are very verbose, this seemed like complete overkill -// #[allow(clippy::missing_docs_in_private_items)] - /// Global error struct for idlefox /// /// This enum represents various errors that can occur when interacting with most of the section of the program diff --git a/src/votes/events.rs b/src/votes/events.rs index daf4318..9f0973b 100644 --- a/src/votes/events.rs +++ b/src/votes/events.rs @@ -11,7 +11,6 @@ //! to track and manage the progression of each voting event according to //! predefined rules and conditions. -#![allow(clippy::missing_docs_in_private_items)] use std::fmt::Display; use chrono::NaiveDateTime; @@ -21,9 +20,13 @@ use crate::{date::NaiveDateList, io::VoteContainer, IdleError}; use super::Ballot; +/// A pending event, waiting to be opened. In this state the even can be safely modified +/// and either manual input or the autostart date will start the vote. #[derive(Serialize, Deserialize, Default)] #[cfg_attr(test, derive(Clone))] pub struct EventPending { + /// The parsed representation of the vote associated with this event. + /// It holds the details required for the voting process. pub(super) parsed_vote: ParsedVote, } @@ -37,7 +40,10 @@ impl EventPending { #[derive(Serialize, Deserialize)] #[cfg_attr(test, derive(Clone))] +// An ongoing event, waiting to be closed thus allowing the ballots to be counted. pub struct EventOngoing { + /// The parsed representation of the vote associated with this event. + /// It holds the details required for the voting process. pub(super) parsed_vote: ParsedVote, } @@ -57,7 +63,15 @@ impl EventOngoing { #[derive(Serialize, Deserialize)] #[cfg_attr(test, derive(Clone))] +/// A closed event, while the users cannot interract with it in this state, +/// this event can still be reopened and it's results can be read. +/// All events have an expiry date and in this state the event will be cleaned +/// up after a while. +/// +/// Closing an event will call the cleanup and completion functions. pub struct EventClosed { + /// The parsed representation of the vote associated with this event. + /// It holds the details required for the voting process. pub(super) parsed_vote: ParsedVote, } @@ -74,8 +88,6 @@ pub(super) struct ParsedVote { pub(super) title: String, /// Description of the event pub(super) description: String, - // /// The global status of the vote - // pub(super) status: EventStatus, /// Date at which to autostart the vote process pub(super) launch_date: NaiveDateTime, /// Date at which to autoclose the vote process @@ -86,24 +98,9 @@ pub(super) struct ParsedVote { pub(super) votes: Vec, /// The list of values to vote for, this list all the valid dates to vote for pub(super) list_candidates: NaiveDateList, - // / The vote type } impl ParsedVote { - // #[allow(dead_code, unused_variables)] - // pub(crate) fn new( - // title: String, - // description: String, - // status: EventStatus, - // launch_date: NaiveDateTime, - // close_date: NaiveDateTime, - // // ballots: Vec, - // list_candidates: NaiveDateList, - // ) -> Self { - // // Have a rather smart close date if not specified - // todo!() - // } - /// All the logic behind a vote becoming live pub(super) fn launch(&mut self) -> Result<(), IdleError> { // TODO: Define this