chore: Clean up util dependencies. (#9247)
This allows this crate to start building sooner + it reduces our total build graph size by 13 units (1104 -> 1091). Release Notes: - N.A
This commit is contained in:
parent
c09fe1ce8a
commit
34f09bae4f
6 changed files with 63 additions and 81 deletions
|
@ -1,8 +1,8 @@
|
|||
use std::path::Path;
|
||||
|
||||
use smol::{fs, stream::StreamExt};
|
||||
|
||||
use crate::ResultExt;
|
||||
use async_fs as fs;
|
||||
use futures_lite::StreamExt;
|
||||
|
||||
/// Removes all files and directories matching the given predicate
|
||||
pub async fn remove_matching<F>(dir: &Path, predicate: F)
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
use crate::http_proxy_from_env;
|
||||
pub use anyhow::{anyhow, Result};
|
||||
use futures::future::BoxFuture;
|
||||
use futures_lite::FutureExt;
|
||||
use isahc::config::{Configurable, RedirectPolicy};
|
||||
pub use isahc::{
|
||||
http::{Method, StatusCode, Uri},
|
||||
Error,
|
||||
};
|
||||
pub use isahc::{AsyncBody, Request, Response};
|
||||
use parking_lot::Mutex;
|
||||
use smol::future::FutureExt;
|
||||
#[cfg(feature = "test-support")]
|
||||
use std::fmt;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use std::{
|
||||
sync::{Arc, Mutex},
|
||||
time::Duration,
|
||||
};
|
||||
pub use url::Url;
|
||||
|
||||
/// An [`HttpClient`] that has a base URL.
|
||||
|
@ -31,22 +33,30 @@ impl HttpClientWithUrl {
|
|||
|
||||
/// Returns the base URL.
|
||||
pub fn base_url(&self) -> String {
|
||||
self.base_url.lock().clone()
|
||||
self.base_url
|
||||
.lock()
|
||||
.map_or_else(|_| Default::default(), |url| url.clone())
|
||||
}
|
||||
|
||||
/// Sets the base URL.
|
||||
pub fn set_base_url(&self, base_url: impl Into<String>) {
|
||||
*self.base_url.lock() = base_url.into();
|
||||
let base_url = base_url.into();
|
||||
self.base_url
|
||||
.lock()
|
||||
.map(|mut url| {
|
||||
*url = base_url;
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
||||
/// Builds a URL using the given path.
|
||||
pub fn build_url(&self, path: &str) -> String {
|
||||
format!("{}{}", self.base_url.lock(), path)
|
||||
format!("{}{}", self.base_url(), path)
|
||||
}
|
||||
|
||||
/// Builds a Zed API URL using the given path.
|
||||
pub fn build_zed_api_url(&self, path: &str) -> String {
|
||||
let base_url = self.base_url.lock().clone();
|
||||
let base_url = self.base_url();
|
||||
let base_api_url = match base_url.as_ref() {
|
||||
"https://zed.dev" => "https://api.zed.dev",
|
||||
"https://staging.zed.dev" => "https://api-staging.zed.dev",
|
||||
|
|
|
@ -7,7 +7,6 @@ mod semantic_version;
|
|||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub mod test;
|
||||
|
||||
pub use backtrace::Backtrace;
|
||||
use futures::Future;
|
||||
use lazy_static::lazy_static;
|
||||
use rand::{seq::SliceRandom, Rng};
|
||||
|
@ -32,7 +31,7 @@ macro_rules! debug_panic {
|
|||
if cfg!(debug_assertions) {
|
||||
panic!( $($fmt_arg)* );
|
||||
} else {
|
||||
let backtrace = $crate::Backtrace::new();
|
||||
let backtrace = std::backtrace::Backtrace::capture();
|
||||
log::error!("{}\n{:?}", format_args!($($fmt_arg)*), backtrace);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue