Optimization: Box variants in Error to reduce size and remove unused variants in BinstallError (#530)

* Box `HttpError` in `binsalk_downloader::remote::Error::Http`
   as `HttpError` contains `Url` which are too big.
* Box `HttpError` in `BinstallError::Http` same as the previous commit.
* Box `TinyTemplateError` in `BinstallError::Template`
  since `TinyTemplateError` is 56 bytes large where most of the other variants are below 40 bytes large.
* Rm unsed variant `BinstallError::VersionUnavailable`
* Box `CratesIoApiError` in `BinstallError::CratesIoApi`
   It is 32 bytes large while other variants are below 40 bytes large.
* Improve err msg for `BinstallError::CrateContext`
* Rm unused variant `BinstallError::VersionReq`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-11-15 00:46:32 +11:00 committed by GitHub
parent 933c6425ef
commit c34a2850b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 37 deletions

View file

@ -29,7 +29,7 @@ pub enum Error {
Reqwest(#[from] reqwest::Error),
#[error(transparent)]
Http(HttpError),
Http(Box<HttpError>),
}
#[derive(Debug, ThisError)]
@ -138,7 +138,7 @@ impl Client {
Ok(response)
}
})
.map_err(|err| Error::Http(HttpError { method, url, err }))
.map_err(|err| Error::Http(Box::new(HttpError { method, url, err })))
}
/// Check if remote exists using `method`.