automatons_github/resource/
mod.rs

1//! Resources on GitHub
2//!
3//! The GitHub integration enables the [automatons] framework to interact with resources on GitHub.
4//! These resources are modelled as strongly-typed data types in this module, and each model maps to
5//! a resource in [GitHub's REST API](https://docs.github.com/en/rest).
6//!
7//! [automatons]: https://github.com/devxbots/automatons
8
9use serde::{Deserialize, Serialize};
10
11use crate::name;
12
13pub use self::account::{Account, AccountId, AccountType, Login};
14pub use self::app::{App, AppId, AppName, AppSlug};
15pub use self::check_run::{
16    CheckRun, CheckRunConclusion, CheckRunId, CheckRunName, CheckRunOutput, CheckRunOutputSummary,
17    CheckRunOutputTitle, CheckRunStatus,
18};
19pub use self::check_suite::{CheckSuite, CheckSuiteId, MinimalCheckSuite};
20pub use self::file::File;
21pub use self::git::{GitRef, GitSha};
22pub use self::installation::{Installation, InstallationId};
23pub use self::license::{License, LicenseKey, LicenseName, SpdxId};
24pub use self::organization::{Organization, OrganizationId};
25pub use self::pull_request::{PullRequest, PullRequestBranch, PullRequestId, PullRequestNumber};
26pub use self::repository::{
27    MinimalRepository, Repository, RepositoryFullName, RepositoryId, RepositoryName,
28};
29pub use self::visibility::Visibility;
30
31mod account;
32mod app;
33mod check_run;
34mod check_suite;
35mod file;
36mod git;
37mod installation;
38mod license;
39mod organization;
40mod pull_request;
41mod repository;
42mod visibility;
43
44name!(
45    /// Unique identifier used with GitHub's GraphQL API
46    ///
47    /// GitHub assigns a unique `node_id` to most resources on the platform, which identifies the
48    /// resource in [GitHub's GraphQL API](https://docs.github.com/en/graphql).
49    NodeId
50);
51
52/// Field with multiple representations
53///
54/// GitHub truncates data types in some API responses and webhook events to reduce the payload size.
55/// The `Field` enum represents fields in responses that have different representations based on
56/// context.
57#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Deserialize, Serialize)]
58#[serde(untagged)]
59pub enum Field<Minimal, Full> {
60    /// Minimal representation of the field
61    Minimal(Minimal),
62
63    /// Full representation of the field
64    Full(Full),
65}
66
67#[cfg(test)]
68mod tests {
69    use super::NodeId;
70
71    #[test]
72    fn trait_send() {
73        fn assert_send<T: Send>() {}
74        assert_send::<NodeId>();
75    }
76
77    #[test]
78    fn trait_sync() {
79        fn assert_sync<T: Sync>() {}
80        assert_sync::<NodeId>();
81    }
82}