1#[derive(Eq, PartialEq, Debug, Clone)]
5pub enum RegistryAuth {
6 Anonymous,
8 Basic(String, String),
10 Bearer(String),
12}
13
14pub(crate) trait Authenticable {
15 fn apply_authentication(self, auth: &RegistryAuth) -> Self;
16}
17
18impl Authenticable for reqwest::RequestBuilder {
19 fn apply_authentication(self, auth: &RegistryAuth) -> Self {
20 match auth {
21 RegistryAuth::Anonymous => self,
22 RegistryAuth::Basic(username, password) => self.basic_auth(username, Some(password)),
23 RegistryAuth::Bearer(token) => self.bearer_auth(token),
24 }
25 }
26}