1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (C) 2023  Aravinth Manivannan <realaravinth@batsense.net>
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: MIT

//! Assets that constitute a release for a given tag.
use serde::{Deserialize, Serialize};

/// Assets that constitute a release for a given tag.
#[derive(Clone, Debug, Serialize, Deserialize, Default, Eq, PartialEq)]
pub struct Release {
    /// Unique identifier
    pub index: usize,

    /// Git tag name of the release.
    pub tag_name: String,

    /// Specifies the commitish value that determines where the Git tag is created from. Can be any
    /// branch or commit SHA. Unused if the Git tag already exists.
    pub target_commitish: Option<String>,

    /// The name of the release
    pub name: String,

    /// Text describing the contents of the release.
    pub body: String,

    /// True if the release is a draft.
    pub draft: bool,

    /// True if the release is a pre-release.
    pub prerelease: bool,

    /// Unique identifier of the user who authored the release.
    pub publisher_id: usize,

    /// Name of the user who authored the release.
    pub publisher_name: String,

    /// Email of the user who authored the release.
    pub publisher_email: Option<String>,

    /// List of assets associated with the release.
    pub assets: Option<Vec<ReleaseAsset>>,

    // TODO: add validation for format "date-time"
    /// Creation time
    pub created: String,

    // TODO: add validation for format "date-time"
    /// Publication time.
    pub published: String,
}

/// A file associated with a release.
#[derive(Clone, Debug, Serialize, Deserialize, Default, Eq, PartialEq)]
pub struct ReleaseAsset {
    /// Unique identifier of the release asset.
    pub index: usize,

    /// The name of the release asset.
    pub name: String,

    /// The content type of the release asset (application/zip, etc.).
    pub content_type: String,

    /// Size in bytes of the release asset.
    pub size: String,

    /// The number of times the release asset was downloaded.
    pub download_count: usize,

    // TODO: add validation for format "date-time"
    /// Creation time
    pub created: String,

    // TODO: add validation for format "date-time"
    /// Last update time.
    pub updated: String,

    /// The URL from which the release asset can be downloaded.
    pub download_url: String,
}