f3-rs/src/issue.rs

91 lines
2.8 KiB
Rust

/*
* Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//! Issues associated to a repository within a forge (Gitea, GitLab, etc.).
use serde::{Deserialize, Serialize};
use crate::Reaction;
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
/// states of an issue
pub enum IssueState {
/// A 'closed' issue will not see any activity in the future
Closed,
/// An 'open' issue will see activity in the future
Open,
}
impl Default for IssueState {
fn default() -> Self {
Self::Open
}
}
/// Issues associated to a repository within a forge (Gitea, GitLab, etc.).
#[derive(Clone, Debug, Serialize, Deserialize, Default, Eq, PartialEq)]
pub struct Issue {
/// Unique identifier, relative to the repository
pub index: usize,
/// Unique identifier of the user who authored the issue.
pub poster_id: usize,
/// Short description displayed as the title.
pub title: String,
/// Long, multiline, description
pub content: String,
/// Target branch in the repository.
///
/// NOTE: Actual property is called "ref" but it is a keyword in Rust so we are using
/// "reference". However, "reference" will automatically be renamed to "ref" while serializing
/// and vice versa
#[serde(rename(serialize = "ref", deserialize = "ref"))]
pub reference: Option<String>,
/// Name of the milestone
pub milestone: Option<String>,
/// state of the issue
pub state: IssueState,
/// A locked issue can only be modified by privileged users
pub is_locked: bool,
// TODO: add validation for format "date-time"
/// Creating time
pub created: String,
// TODO: add validation for format "date-time"
/// Last update time
pub updated: String,
// TODO: add validation for format "date-time"
/// The last time 'state' changed to 'closed'
pub closed: Option<String>,
/// List of labels.
pub labels: Option<Vec<String>>,
/// Multiline content of the comment
pub reactions: Option<Vec<Reaction>>,
/// List of assignees.
pub assignees: Option<Vec<String>>,
}