diff options
author | Cyborus <cyborus@cyborus.xyz> | 2023-12-15 18:02:39 +0100 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2023-12-15 18:02:39 +0100 |
commit | 96124821ba0f9b9cb5d1bf97be5faed1165a51b1 (patch) | |
tree | 364af3a378a0eae42f8c7e0d35a7f583bf03db25 /src | |
parent | add download test (diff) | |
download | forgejo-api-96124821ba0f9b9cb5d1bf97be5faed1165a51b1.tar.xz forgejo-api-96124821ba0f9b9cb5d1bf97be5faed1165a51b1.zip |
format
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 7 | ||||
-rw-r--r-- | src/repository.rs | 26 |
2 files changed, 27 insertions, 6 deletions
@@ -180,9 +180,12 @@ impl Forgejo { status => Err(ForgejoError::UnexpectedStatusCode(status)), } } - + /// Like `execute`, but returns a `String`. - async fn execute_opt_raw(&self, request: Request) -> Result<Option<bytes::Bytes>, ForgejoError> { + async fn execute_opt_raw( + &self, + request: Request, + ) -> Result<Option<bytes::Bytes>, ForgejoError> { let response = self.client.execute(request).await?; match response.status() { status if status.is_success() => Ok(Some(response.bytes().await?)), diff --git a/src/repository.rs b/src/repository.rs index 992f78a..d9a92b1 100644 --- a/src/repository.rs +++ b/src/repository.rs @@ -207,7 +207,12 @@ impl Forgejo { .await } - pub async fn download_release_zip(&self, owner: &str, repo: &str, release: u64) -> Result<Option<bytes::Bytes>, ForgejoError> { + pub async fn download_release_zip( + &self, + owner: &str, + repo: &str, + release: u64, + ) -> Result<Option<bytes::Bytes>, ForgejoError> { let release = self.get_release(owner, repo, release).await; let release = match release { Ok(Some(release)) => release, @@ -218,7 +223,12 @@ impl Forgejo { self.execute_opt_raw(request).await } - pub async fn download_release_tarball(&self, owner: &str, repo: &str, release: u64) -> Result<Option<bytes::Bytes>, ForgejoError> { + pub async fn download_release_tarball( + &self, + owner: &str, + repo: &str, + release: u64, + ) -> Result<Option<bytes::Bytes>, ForgejoError> { let release = self.get_release(owner, repo, release).await; let release = match release { Ok(Some(release)) => release, @@ -229,8 +239,16 @@ impl Forgejo { self.execute_opt_raw(request).await } - pub async fn download_release_attachment(&self, owner: &str, repo: &str, release: u64, attach: u64) -> Result<Option<bytes::Bytes>, ForgejoError> { - let release = self.get_release_attachment(owner, repo, release, attach).await?; + pub async fn download_release_attachment( + &self, + owner: &str, + repo: &str, + release: u64, + attach: u64, + ) -> Result<Option<bytes::Bytes>, ForgejoError> { + let release = self + .get_release_attachment(owner, repo, release, attach) + .await?; let request = self.client.get(release.browser_download_url).build()?; self.execute_opt_raw(request).await } |