summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesper Jensen <jesper@jnsn.dev>2026-02-07 22:17:38 +0100
committerJesper Jensen <jesper@jnsn.dev>2026-02-07 22:17:38 +0100
commit313e6d1a1788e153f8ecdb14db0f1d44dc270998 (patch)
tree5436e468b10a8e965e6394fac792dbe6f62bce0e
parent74c458501a749a12e1cea04dd6656d07a77b2426 (diff)
Inline the auth struct
-rw-r--r--src/registry.rs32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/registry.rs b/src/registry.rs
index c23a395..45cf625 100644
--- a/src/registry.rs
+++ b/src/registry.rs
@@ -59,23 +59,6 @@ struct AuthState {
stage: AuthStage,
}
-struct Auth {
- states: HashMap<String, AuthState>,
-}
-
-impl Auth {
- fn new(infos: Vec<AuthInfo>) -> Self {
- let mut states = HashMap::new();
- for info in infos {
- states.insert(info.host.clone(), AuthState {
- info: info,
- stage: AuthStage::Idle,
- });
- }
-
- return Auth { states };
- }
-}
impl AuthState {
fn add_to_request<T>(&self, req: ureq::RequestBuilder<T>) -> ureq::RequestBuilder<T> {
@@ -165,14 +148,19 @@ enum RegistryError {
}
pub struct HttpRegistry {
- auth: RefCell<Auth>,
+ auth: RefCell<HashMap<String, AuthState>>,
}
impl HttpRegistry {
pub fn new(infos: Vec<AuthInfo>) -> Self {
- return HttpRegistry {
- auth: RefCell::new(Auth::new(infos)),
- };
+ let mut states = HashMap::new();
+ for info in infos {
+ states.insert(info.host.clone(), AuthState {
+ info: info,
+ stage: AuthStage::Idle,
+ });
+ }
+ return HttpRegistry { auth: RefCell::new(states) };
}
fn perform_request(
@@ -182,7 +170,7 @@ impl HttpRegistry {
accept: &'static str,
) -> Result<ureq::http::Response<ureq::Body>, RegistryError> {
let mut auth = self.auth.borrow_mut();
- let mut state = auth.states.get_mut(registry);
+ let mut state = auth.get_mut(registry);
let url = format!("https://{}{}", registry, &url);