Move the Release info structs to new tree
This commit is contained in:
32
src/lib.rs
32
src/lib.rs
@@ -4,36 +4,6 @@ pub mod cli;
|
|||||||
pub mod api;
|
pub mod api;
|
||||||
pub mod structs;
|
pub mod structs;
|
||||||
|
|
||||||
/// A struct matching a Gitea "Release" entry
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
|
||||||
pub struct ReleaseInfo {
|
|
||||||
id: usize,
|
|
||||||
tag_name: String,
|
|
||||||
target_commitish: String,
|
|
||||||
name: String,
|
|
||||||
body: String,
|
|
||||||
url: String,
|
|
||||||
html_url: String,
|
|
||||||
tarball_url: String,
|
|
||||||
zipball_url: String,
|
|
||||||
upload_url: String,
|
|
||||||
draft: bool,
|
|
||||||
prerelease: bool,
|
|
||||||
created_at: String,
|
|
||||||
published_at: String,
|
|
||||||
author: Author,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Author {
|
|
||||||
id: usize,
|
|
||||||
login: String,
|
|
||||||
login_name: String,
|
|
||||||
source_id: usize,
|
|
||||||
full_name: String,
|
|
||||||
email: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct CreateReleaseOption {
|
pub struct CreateReleaseOption {
|
||||||
pub body: String,
|
pub body: String,
|
||||||
@@ -53,7 +23,7 @@ pub struct ApiError {
|
|||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum CreateResult {
|
pub enum CreateResult {
|
||||||
Success(ReleaseInfo),
|
Success(structs::release::Release),
|
||||||
ErrWithMessage(ApiError),
|
ErrWithMessage(ApiError),
|
||||||
Empty,
|
Empty,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use gt_tools::CreateReleaseOption;
|
use gt_tools::CreateReleaseOption;
|
||||||
use gt_tools::{ReleaseInfo, cli::Args};
|
use gt_tools::{structs::release::Release, cli::Args};
|
||||||
use reqwest::multipart::Part;
|
use reqwest::multipart::Part;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@@ -76,7 +76,7 @@ async fn do_list_releases(
|
|||||||
client: &reqwest::Client,
|
client: &reqwest::Client,
|
||||||
gitea_url: &str,
|
gitea_url: &str,
|
||||||
repo: &str,
|
repo: &str,
|
||||||
) -> Result<Vec<ReleaseInfo>, Error> {
|
) -> Result<Vec<Release>, Error> {
|
||||||
let request_url = format!(
|
let request_url = format!(
|
||||||
"{gitea_url}{front}{repo}{back}",
|
"{gitea_url}{front}{repo}{back}",
|
||||||
front = API_RELEASE_FRONT,
|
front = API_RELEASE_FRONT,
|
||||||
@@ -91,7 +91,7 @@ async fn do_list_releases(
|
|||||||
// TODO: Handle case with no releases.
|
// TODO: Handle case with no releases.
|
||||||
// afaict: Serde tries to unpack an empty list, can't decide what struct it's unpacking,
|
// afaict: Serde tries to unpack an empty list, can't decide what struct it's unpacking,
|
||||||
// and emits an error. Desired behavior: empty Vec.
|
// and emits an error. Desired behavior: empty Vec.
|
||||||
let body_text: Vec<ReleaseInfo> = response.json().await?;
|
let body_text: Vec<Release> = response.json().await?;
|
||||||
return Ok(body_text);
|
return Ok(body_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,33 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub struct Release;
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct Release {
|
||||||
|
id: usize,
|
||||||
|
tag_name: String,
|
||||||
|
target_commitish: String,
|
||||||
|
name: String,
|
||||||
|
body: String,
|
||||||
|
url: String,
|
||||||
|
html_url: String,
|
||||||
|
tarball_url: String,
|
||||||
|
zipball_url: String,
|
||||||
|
upload_url: String,
|
||||||
|
draft: bool,
|
||||||
|
prerelease: bool,
|
||||||
|
created_at: String,
|
||||||
|
published_at: String,
|
||||||
|
author: Author,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct Author {
|
||||||
|
id: usize,
|
||||||
|
login: String,
|
||||||
|
login_name: String,
|
||||||
|
source_id: usize,
|
||||||
|
full_name: String,
|
||||||
|
email: String,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct CreateReleaseOption;
|
pub struct CreateReleaseOption;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user