mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-06 12:10:02 +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
|
@ -28,6 +28,9 @@ pub use certificate::Certificate;
|
|||
mod request_builder;
|
||||
pub use request_builder::{RequestBuilder, Response};
|
||||
|
||||
#[cfg(feature = "json")]
|
||||
pub use request_builder::JsonError;
|
||||
|
||||
const MAX_RETRY_DURATION: Duration = Duration::from_secs(120);
|
||||
const MAX_RETRY_COUNT: u8 = 3;
|
||||
const DEFAULT_RETRY_DURATION_FOR_RATE_LIMIT: Duration = Duration::from_millis(200);
|
||||
|
@ -35,12 +38,17 @@ const RETRY_DURATION_FOR_TIMEOUT: Duration = Duration::from_millis(200);
|
|||
const DEFAULT_MIN_TLS: tls::Version = tls::Version::TLS_1_2;
|
||||
|
||||
#[derive(Debug, ThisError)]
|
||||
#[non_exhaustive]
|
||||
pub enum Error {
|
||||
#[error("Reqwest error: {0}")]
|
||||
Reqwest(#[from] reqwest::Error),
|
||||
|
||||
#[error(transparent)]
|
||||
Http(Box<HttpError>),
|
||||
|
||||
#[cfg(feature = "json")]
|
||||
#[error("Failed to parse http response body as Json: {0}")]
|
||||
Json(#[from] JsonError),
|
||||
}
|
||||
|
||||
#[derive(Debug, ThisError)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue