mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-12 06:50:02 +00:00
Refactor: Extract helpers::cratesio_url
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
5ca1278c22
commit
cc13aa911f
2 changed files with 11 additions and 6 deletions
|
@ -10,7 +10,7 @@ use bytes::Bytes;
|
|||
use cargo_toml::Manifest;
|
||||
use futures_util::stream::Stream;
|
||||
use log::debug;
|
||||
use once_cell::sync::OnceCell;
|
||||
use once_cell::sync::{Lazy, OnceCell};
|
||||
use reqwest::{tls, Client, ClientBuilder, Method, Response};
|
||||
use serde::Serialize;
|
||||
use tempfile::NamedTempFile;
|
||||
|
@ -55,6 +55,13 @@ pub fn cargo_home() -> Result<&'static Path, io::Error> {
|
|||
.map(ops::Deref::deref)
|
||||
}
|
||||
|
||||
pub fn cratesio_url() -> &'static Url {
|
||||
static CRATESIO: Lazy<Url, fn() -> Url> =
|
||||
Lazy::new(|| url::Url::parse("https://github.com/rust-lang/crates.io-index").unwrap());
|
||||
|
||||
&*CRATESIO
|
||||
}
|
||||
|
||||
/// Returned file is readable and writable.
|
||||
pub fn create_if_not_exist(path: impl AsRef<Path>) -> io::Result<fs::File> {
|
||||
let path = path.as_ref();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue