oci_distribution/
secrets.rs

1//! Types for working with registry access secrets
2
3/// A method for authenticating to a registry
4#[derive(Eq, PartialEq, Debug, Clone)]
5pub enum RegistryAuth {
6    /// Access the registry anonymously
7    Anonymous,
8    /// Access the registry using HTTP Basic authentication
9    Basic(String, String),
10}
11
12pub(crate) trait Authenticable {
13    fn apply_authentication(self, auth: &RegistryAuth) -> Self;
14}
15
16impl Authenticable for reqwest::RequestBuilder {
17    fn apply_authentication(self, auth: &RegistryAuth) -> Self {
18        match auth {
19            RegistryAuth::Anonymous => self,
20            RegistryAuth::Basic(username, password) => self.basic_auth(username, Some(password)),
21        }
22    }
23}