refactor: api cleanup (#7812)

* refactor(config): unify YAML persistence

* refactor(config): remove redundant config APIs

* refactor(config): remove unused config APIs

* refactor(config): narrow profile APIs

* fix(config): preserve profiles on invalid reorder

* refactor(startup): narrow resolve helpers

* refactor(config): unify mixed port defaults

* refactor(network): simplify response APIs

* refactor(config): make profile builders infallible

* refactor(config): make profile activation infallible

* refactor(api): simplify internal runtime APIs

* refactor: consolidate internal config and window APIs
This commit is contained in:
Tunglies
2026-08-25 07:19:17 +00:00
committed by GitHub
parent 272c09568c
commit b7c4f7d39b
29 changed files with 277 additions and 413 deletions
+6 -29
View File
@@ -18,7 +18,7 @@ pub struct HttpResponse {
}
impl HttpResponse {
pub const fn new(status: StatusCode, headers: HeaderMap, body: String) -> Self {
const fn new(status: StatusCode, headers: HeaderMap, body: String) -> Self {
Self { status, headers, body }
}
@@ -30,8 +30,8 @@ impl HttpResponse {
&self.headers
}
pub fn text_with_charset(&self) -> Result<&str> {
Ok(&self.body)
pub fn text(&self) -> &str {
&self.body
}
}
@@ -50,12 +50,6 @@ enum TlsRootMode {
pub struct NetworkManager;
impl Default for NetworkManager {
fn default() -> Self {
Self::new()
}
}
impl NetworkManager {
pub const fn new() -> Self {
Self
@@ -161,23 +155,6 @@ impl NetworkManager {
detail.contains("protocolversion") || detail.contains("protocol version")
}
pub async fn create_request(
&self,
proxy_type: ProxyType,
timeout_secs: Option<u64>,
user_agent: Option<String>,
accept_invalid_certs: bool,
) -> Result<Client> {
self.create_request_with_tls_mode(
proxy_type,
timeout_secs,
user_agent,
accept_invalid_certs,
TlsRootMode::PlatformVerifier,
)
.await
}
async fn get_with_tls_mode(
&self,
url: &str,
@@ -279,7 +256,7 @@ impl NetworkManager {
self.build_client(proxy_url, headers, accept_invalid_certs, timeout_secs, tls_root_mode)
}
pub async fn get_with_interrupt(
pub async fn get(
&self,
url: &str,
proxy_type: ProxyType,
@@ -355,8 +332,8 @@ impl NetworkManager {
Ok(body)
}
/// Downloads a binary body, mirroring the TLS fallback of [`Self::get_with_interrupt`].
pub async fn get_bytes_with_interrupt(
/// Downloads a binary body, mirroring the TLS fallback of [`Self::get`].
pub async fn get_bytes(
&self,
url: &str,
proxy_type: ProxyType,