Skip to main content

subspace_contracts/issues/
summary.rs

1//! Optional reference-card facts. Older responders can keep supplying only the title and state.
2
3use super::IssueState;
4
5mod details;
6mod facts;
7pub use facts::{IssuePerson, IssueProgress, LatestActivity, PullRequestSummary};
8
9/// A short issue summary, held only within the current viewer session.
10#[derive(Clone, PartialEq, Eq)]
11#[non_exhaustive]
12pub struct IssueSummary {
13    pub identifier: String,
14    pub title: String,
15    /// Plain text explaining the problem this issue solves; absent on older issues.
16    pub summary: Option<String>,
17    /// The issue's navigation URL, handled by the responding board.
18    pub url: String,
19    pub state: IssueState,
20    pub tracker: bool,
21    pub archived: bool,
22    /// The assignee's display name.
23    pub assignee: Option<String>,
24    details: Option<Box<details::Details>>,
25}
26
27impl IssueSummary {
28    pub fn new(identifier: &str, title: &str, url: &str, state: IssueState) -> Self {
29        Self {
30            identifier: identifier.into(),
31            title: title.into(),
32            summary: None,
33            url: url.into(),
34            state,
35            tracker: false,
36            archived: false,
37            assignee: None,
38            details: None,
39        }
40    }
41
42    /// Whether the issue is a tracker and whether it is archived.
43    pub fn with_markers(mut self, tracker: bool, archived: bool) -> Self {
44        self.tracker = tracker;
45        self.archived = archived;
46        self
47    }
48
49    pub fn with_summary(mut self, summary: Option<&str>) -> Self {
50        self.summary = summary.map(str::to_owned);
51        self
52    }
53
54    pub fn with_assignee(mut self, assignee: Option<&str>) -> Self {
55        self.assignee = assignee.map(str::to_owned);
56        self
57    }
58}