feat: define Issue

This commit is contained in:
Aravinth Manivannan 2023-01-03 12:53:10 +05:30
parent e47c3cf6bb
commit 7003b3ff05
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 92 additions and 0 deletions

90
src/issue.rs Normal file
View file

@ -0,0 +1,90 @@
/*
* 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>>,
}

View file

@ -20,6 +20,7 @@
//! This is an incomplete Rust port of the F3 library created by the ForgeFriends project. //! This is an incomplete Rust port of the F3 library created by the ForgeFriends project.
pub mod comment; pub mod comment;
pub mod identities; pub mod identities;
pub mod issue;
pub mod label; pub mod label;
pub mod reaction; pub mod reaction;
pub mod repository; pub mod repository;
@ -28,6 +29,7 @@ pub mod user;
pub use comment::Comment; pub use comment::Comment;
pub use identities::Identities; pub use identities::Identities;
pub use issue::Issue;
pub use label::Label; pub use label::Label;
pub use reaction::Reaction; pub use reaction::Reaction;
pub use repository::Repository; pub use repository::Repository;