1use crate::types::request::{self, Authentication, Credential, CredentialValue, Password, Username};
4
5#[derive(Debug)]
6pub enum CredentialType {
7 UsernameAndPassword(UsernameAndPasswordCredential),
8}
9
10#[derive(Debug)]
11pub struct UsernameAndPasswordCredential {
12 pub username: String,
13 pub password: Option<String>,
14}
15
16impl UsernameAndPasswordCredential {
17 pub fn new(username: String, password: Option<String>) -> Self {
18 Self { username, password }
19 }
20}
21
22impl Authentication {
23 pub fn build(credential: CredentialType) -> Authentication {
24 match credential {
25 CredentialType::UsernameAndPassword(inner) => {
26 let username = Username(inner.username);
27 let password = inner.password.map(Password);
28 Authentication(Credential(
29 request::CredentialType::UsernameAndPassword,
30 CredentialValue::UsernameAndPassword(username, password),
31 ))
32 }
33 }
34 }
35}