1use reqwest::RequestBuilder;
2
3#[derive(Clone, Debug)]
4pub enum RegistryAuth {
5 Anonymous,
6 Basic { username: String, password: String },
7}
8
9impl RegistryAuth {
10 pub fn anonymous() -> Self {
11 RegistryAuth::Anonymous
12 }
13
14 pub fn basic(username: impl Into<String>, password: impl Into<String>) -> Self {
15 RegistryAuth::Basic {
16 username: username.into(),
17 password: password.into(),
18 }
19 }
20
21 pub fn apply(&self, req: RequestBuilder) -> RequestBuilder {
22 match self {
23 RegistryAuth::Anonymous => req,
24 RegistryAuth::Basic { username, password } => req.basic_auth(username, Some(password)),
25 }
26 }
27}