From def448d36d8f718785da3a0001194399617b3990 Mon Sep 17 00:00:00 2001 From: Kornel Date: Sat, 11 Apr 2020 12:46:57 +0100 Subject: Unused --- github_v3/src/model.rs | 187 ------------------------------------------------- 1 file changed, 187 deletions(-) delete mode 100644 github_v3/src/model.rs diff --git a/github_v3/src/model.rs b/github_v3/src/model.rs deleted file mode 100644 index 5a81c5f..0000000 --- a/github_v3/src/model.rs +++ /dev/null @@ -1,187 +0,0 @@ -#[derive(Debug, Copy, Eq, PartialEq, Clone)] -pub enum UserType { - Org, - User, - Bot, -} - -use serde::de; -use serde::de::{Deserializer, Visitor}; -use serde::Serializer; -use serde_derive::Deserialize; -use serde_derive::Serialize; -use std::fmt; - -/// Case-insensitive enum -impl<'de> serde::Deserialize<'de> for UserType { - fn deserialize(deserializer: D) -> Result - where D: Deserializer<'de>, - { - struct UserTypeVisitor; - - impl<'a> Visitor<'a> for UserTypeVisitor { - type Value = UserType; - - fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("user/org/bot") - } - - fn visit_str(self, v: &str) -> Result { - match v.to_ascii_lowercase().as_str() { - "org" | "organization" => Ok(UserType::Org), - "user" => Ok(UserType::User), - "bot" => Ok(UserType::Bot), - x => Err(de::Error::unknown_variant(x, &["user", "org", "bot"])), - } - } - - fn visit_string(self, v: String) -> Result { - self.visit_str(&v) - } - } - - deserializer.deserialize_string(UserTypeVisitor) - } -} - -impl serde::Serialize for UserType { - fn serialize(&self, serializer: S) -> Result - where S: Serializer, - { - serializer.serialize_str(match *self { - UserType::User => "user", - UserType::Org => "org", - UserType::Bot => "bot", - }) - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct User { - pub id: u32, - pub login: String, - pub name: Option, - pub avatar_url: Option, // "https://avatars0.githubusercontent.com/u/1111?v=4", - pub gravatar_id: Option, // "", - pub html_url: String, // "https://github.com/zzzz", - pub blog: Option, // "https://example.com - #[serde(rename = "type")] - pub user_type: UserType, - pub created_at: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ContribWeek { - #[serde(rename = "w")] - pub week_timestamp: u32, - #[serde(rename = "a")] - pub added: u32, - #[serde(rename = "d")] - pub deleted: u32, - #[serde(rename = "c")] - pub commits: u32, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct SearchResults { - pub items: Vec, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct UserContrib { - pub total: u32, - pub weeks: Vec, - pub author: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct GitCommitAuthor { - pub date: String, // "2018-04-30T16:24:52Z", - pub email: String, - pub name: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct GitCommit { - pub author: GitCommitAuthor, - pub committer: GitCommitAuthor, - pub message: String, - pub comment_count: u32, - // tree.sha -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct CommitMeta { - pub sha: String, // TODO: deserialize to bin - pub author: Option, - pub committer: Option, - pub commit: GitCommit, - // parents: [{sha}] -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct GitHubRepo { - pub name: String, - pub description: Option, - pub fork: bool, - pub created_at: String, - pub updated_at: Option, - pub pushed_at: Option, - pub homepage: Option, - pub stargazers_count: u32, // Stars - pub forks_count: u32, // Real number of forks - pub subscribers_count: u32, // Real number of watches - pub has_issues: bool, - pub open_issues_count: Option, - // language: JavaScript, - pub has_downloads: bool, - // has_wiki: true, - pub has_pages: bool, - pub archived: bool, - pub default_branch: Option, - pub owner: Option, - #[serde(default)] - pub topics: Vec, - - #[serde(default)] - pub is_template: Vec, - - /// My custom addition! - pub github_page_url: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct GitHubRelease { - // url: Option, // "https://api.github.com/repos/octocat/Hello-World/releases/1", - // html_url: Option, // "https://github.com/octocat/Hello-World/releases/v1.0.0", - // assets_url: Option, // "https://api.github.com/repos/octocat/Hello-World/releases/1/assets", - // upload_url: Option, // "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", - // tarball_url: Option, // "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0", - // zipball_url: Option, // "https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0", - // id: Option, // 1, - // node_id: Option, // "MDc6UmVsZWFzZTE=", - pub tag_name: Option, // "v1.0.0", - // target_commitish: Option, // "master", - // name: Option, // "v1.0.0", - pub body: Option, // "Description of the release", - pub draft: Option, // false, - pub prerelease: Option, // false, - pub created_at: Option, // "2013-02-27T19:35:32Z", - pub published_at: Option, // "2013-02-27T19:35:32Z", -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Topics { - pub names: Vec, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct UserOrg { - pub login: String, // "github", - //id: String, // 1, - // node_id: String, // "MDEyOk9yZ2FuaXphdGlvbjE=", - pub url: String, // "https://api.github.com/orgs/github", - // public_members_url: String, // "https://api.github.com/orgs/github/public_members{/member}", - // avatar_url: String, // "https://github.com/images/error/octocat_happy.gif", - pub description: Option, // "A great organization" -} -- cgit v1.2.3