From 313e6d1a1788e153f8ecdb14db0f1d44dc270998 Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Sat, 7 Feb 2026 22:17:38 +0100 Subject: Inline the auth struct --- src/registry.rs | 32 ++++++++++---------------------- 1 file 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, -} - -impl Auth { - fn new(infos: Vec) -> 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(&self, req: ureq::RequestBuilder) -> ureq::RequestBuilder { @@ -165,14 +148,19 @@ enum RegistryError { } pub struct HttpRegistry { - auth: RefCell, + auth: RefCell>, } impl HttpRegistry { pub fn new(infos: Vec) -> 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, 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); -- cgit v1.2.3