mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-12 15:00:04 +00:00
Replace dep crates_io_api
with in-house solution (#846)
It also uses `max_stable_version` in the json downloaded from https://crates.io/api/v1/crates/$name if possible, which is equivalent to the version shown on https://crates.io/crates/$name . - Add new feat `json` to `binstalk-downloader` - Impl new async fn `Response::json` - use `Response::json` in `GhApiClient` impl - Mark all err types in binstalk-downloader as `non_exhaustive` - Ret `remote::Error` in `remote::Certificate::{from_pem, from_der}` instead of `ReqwestError`. - Refactor `BinstallError`: Merge variant `Unzip`, `Reqwest` & `Http` into one variant `Download`. - Manually download and parse json from httos://crates.io/api/v1 - Remove unused deps `crates_io_api` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
c00d648dac
commit
8eee318ccd
17 changed files with 120 additions and 244 deletions
|
@ -8,22 +8,17 @@ use std::{
|
|||
|
||||
use compact_str::CompactString;
|
||||
use serde::Deserialize;
|
||||
use serde_json::from_slice as json_from_slice;
|
||||
use thiserror::Error as ThisError;
|
||||
use url::Url;
|
||||
|
||||
pub use serde_json::Error as JsonError;
|
||||
|
||||
use super::{remote, GhRelease};
|
||||
|
||||
#[derive(ThisError, Debug)]
|
||||
#[non_exhaustive]
|
||||
pub enum GhApiError {
|
||||
#[error("IO Error: {0}")]
|
||||
Io(#[from] io::Error),
|
||||
|
||||
#[error("Failed to parse json: {0}")]
|
||||
Json(#[from] JsonError),
|
||||
|
||||
#[error("Remote Error: {0}")]
|
||||
Remote(#[from] remote::Error),
|
||||
|
||||
|
@ -129,7 +124,5 @@ pub(super) async fn fetch_release_artifacts(
|
|||
return Ok(FetchReleaseRet::ReleaseNotFound);
|
||||
}
|
||||
|
||||
let bytes = response.error_for_status()?.bytes().await?;
|
||||
|
||||
Ok(FetchReleaseRet::Artifacts(json_from_slice(&bytes)?))
|
||||
Ok(FetchReleaseRet::Artifacts(response.json().await?))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue